4

Is it possible to create a file which contains the information (the contents) of a certain folder? For example:

cat /folder >> file

I also tried

touch /folder >> file

I should add that I need the folders and their folders and files in a recursive way

Anwar
  • 77,855
Sam
  • 715
  • 1
  • 5
  • 9

2 Answers2

5

I would do it by

ls /path/to/folder > outputfile

If you want to see the recursive contents of folders within folders with file permissions, you can use

ls -lR /path/to/folder > outputfile
Pilot6
  • 92,041
1

Do something like

ls >> outputFile

This will pass the output of the ls command to a specified file.

For example, if you are in a folder that contains:

  • File1
  • File2
  • File3

Then running ls >> outputFile will make a file called outputFile that contains

File1 File2 File3

TheOdd
  • 3,012