ls

From Mac Guides

Jump to: navigation, search

ls is a Terminal command used to list the contents of a directory or display information about a file. It has certain advantages over Finder, such as optionally listing invisible files. It has a lot of options, see the man page for details.

Examples

To list the names only of all visible items in the current directory (see cd for information on setting the current directory)

 ls

To list detailed information about all items (visible and invisible) in the current directory (the -a option is to show all files, the -l option is to show details)

 ls -al

To list the contents of your Documents folder and all subfolders (this may take a while if you have a large Documents folder)

 ls -R ~/Documents

Man Page Excerpt

For each operand that names a file of a type other than directory, ls displays its name as well as any requested, associated information. For each operand that names a file of type directory, ls displays the names of files contained within that directory, as well as any requested, associated information.