Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to Retrieve the Names of Files to a txt file??

share|improve this question
Do you mean ls > files.txt ? – sBlatt Nov 4 '10 at 12:49
please elaborate your q. – aneeshep Nov 4 '10 at 12:54
up vote 2 down vote accepted

You can execute

ls -1 >filename

this will redirect the output in the file with the filename given.

For the content of a folder:

ls -1 foldername >filename
share|improve this answer
How can do the same to contents of folders? – Vassilis Nov 4 '10 at 19:05
ls -R >filename – borjacampina Nov 4 '10 at 22:53
And if you want to see directory structure, I like the tree command. – Kees Cook Nov 5 '10 at 0:34
if you want the content of a folder add the folder name to it – txwikinger Nov 5 '10 at 15:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.