Search code examples
linuxls

Create a text file containing list of (relative paths to) files in a directory?


Suppose I am standing on a directory. Inside there's another directory called inside_dir containing a huge number of files. I want to create a file containing a list of all the files inside inside_dir, listed as the relative path to the files. That is, if there is a file called file1 inside inside_dir, the corresponding line in the list file should be inside_dir/file1.

Since the number of files is huge, just doing ls inside_dir/* > list.txt won't work because it will complain about having too many arguments.


Solution

  • find inside_dir -type f > list.txt