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
Other answers
If you use Python, then you can use some of the functions in the os.path module.
Nigel Legg
Related Q & A:
- How can I copy text from Gedit?Best solution by Super User
- How can I copy file from Windows to Ubuntu?Best solution by Super User
- How do i copy my friendlist to a new main yahooaccount?Best solution by Yahoo! Answers
- How do I copy music onto my memory card?Best solution by Yahoo! Answers
- How do I copy and paste a link?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.