Mac-terminal.com

Mac-Terminal.com

An introduction of the Terminal for Mac OS X

ls

Syntax: ls [-Options] <search pattern>

Usage/Result: List the content of the current working directory.

Options:

-ALists all files except . and ..
-aInclude hidden files like files that begins with a dot (.)
-fThe list of files will not be sorted
-lDetailed list view: filesize, ownership, date/time etc.
-hUse readable filesizes like kb/mb/gb instead of just byte size
-RRecursive - will also list the content of eventual subtrees.
-rSort files in reversed order
-SSort files by filesize
-tSort files by when they were last modified
-uSort files by when they were last accessed

Exempel

lsLists all the files in the current working dir.
ls a*Lists all the files that begins with the letter "a" (* is used as a wildcard)
ls *.zipList every file that ends with *.zip
ls -lShrDetailed list (-l) of the current working dir.
-S = Sort by filesize
-h = Use readable filesizes(kb/mb/gb).
-r = Sort files in reversed order

Advanced examples

Usage/Result
ls | moreList files one page at a time. Use "Space" to view the next set of files.