How do I copy multiple file names?

How do I copy the names of files in the directory to the text file?

  • Answer:

    The ls command will give you files as well as directories (and symlinks, and block devices, etc.), and will not descend into subdirectories. The command you're looking for is find: find . -type f > files.txt Note that the list of files will be in unsorted order; you may want to pipe the output through sort before redirecting the output to a file: find . -type f | sort > files.txt If you do not want to descend into subdirectories, use the -maxdepth 1 option. You can also specify multiple directories.

Costya Perepelitsa at Quora Visit the source

Was this solution helpful to you?

Other answers

If you use Python, then you can use some of the functions in the os.path module.

Nigel Legg

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.