Generate a list of contents of any directory using terminal
There are situation in which you need to share a list of all the files in a directory and there is more to it than what you see in viewport if sharing a screenshot is the easier way -
Here's the terminal command to generate a list of all contents of any directory, and export to a text file.
ls -l -R path_to/source/directory > ~/Desktop/file_name.txt
Replace path_to/source/directory
with actual source, or just drag the source directory into the terminal window after ls -l -R
if you're lazy to type the whole path & finish the command with destination+filename before you hit Return
key.
Written by Ben Jacob
Related protips
2 Responses
If you ever want to get a list of files, excluding of all the details (permissions, size, modification times etc) just change -l
to -1
Also, if you only want to copy that list to your keyboard for pasting(with additional formatting options):
ls -alRth | pbcopy