7ubmaw
Last Updated: February 25, 2016
·
462
· benjacob

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.

Say Thanks
Respond

2 Responses
Add your response

4879
43ea08b4fc547e8a5da87c207bea2123

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

over 1 year ago ·
18471
F8c44c0b34eba12c6e3928d90e36cfb5

Also, if you only want to copy that list to your keyboard for pasting(with additional formatting options):

ls -alRth | pbcopy

over 1 year ago ·