This is a quick code scrap – I needed a list of all the files within a directory path on a Linux server today. I need to do this infrequently and never remember the command, so here it is for my own future posterity:
~# find /path/to/scan/ -type f > /tmp/files.txt
The above code will work on any Linux machine supporting the find command, and will dump a list of all files in every sub-directory to /tmp/files.txt
Each line of the file will resemble:
/path/to/scan/file1.txt
/path/to/scan/file2.txt
/path/to/scan/dir1/file3.txt
/path/to/scan/dir1/sub1/file4.txt
/path/to/scan/dir2/file5.txt
(etc)
Edit
I have just recently created a Windows version of this post, available here.
One thought on “Code Scraps: Get a list of all file content in a directory in Linux”