Contents

ls - listing files in a directory

Overview

ls list files in the current working directory. With the -l switch '(long listing)'' it shows details to that files. Most often used is the -latr switch which shows a long listing of the files with the file that was modified last at the end.

ls Command and Parameter


 ls

The most important option are:
-l
long listing with details Details
-a
show hidden files (.* files)
-t
sort by modification time
-r
reverse sort order
type on the Unix Command line
  man ls 
for more details

ls on OS X

There are some addition parameter to ls on Mac OS X:
-@
To list OS X extended attributes from the command line specif the at (@-swictch with the ls command:

 ls -l@ *
 -rw-r--r--@ 1 ckent  staff  225868823 Sep  9  2012 Myfile01.flv
com.apple.FinderInfo 42 com.apple.ResourceFork 41338
-e
To list the OS X access control lists (ACLs) use the -e switch with the Unix ls command

 ls -le  /Applications/Telephone.app 
 total 0
 drwxr-xr-x+ 10 root  wheel  340 30 Mär  2013 Contents
 0: user:_spotlight inherited allow list,search,readattr,readextattr,readsecurity,file_inherit,directory_inherit

Examples - Tips and Tricks


Show latest file last

Most often some one wants to see the files that have been modified. The following command does the rick for you:
 ls -ltr
 drwxr-xr-x  2 ckent  staff   68 27 Okt 13:10 img
 drwxr-xr-x  2 ckent  staff   68 27 Okt 13:10 html
 drwxr-xr-x  2 ckent  staff   68 27 Okt 13:17 etc
 drwxr-xr-x  3 ckent  staff  102 27 Okt 13:17 home
 drwxr-xr-x  3 ckent  staff  102 27 Okt 13:18 contact
 drwxr-xr-x  3 ckent  staff  102 27 Okt 13:18 news
 drwxr-xr-x  3 ckent  staff  102 27 Okt 13:18 products
 drwxr-xr-x  6 ckent  staff  204 27 Okt 13:26 gallery2
 drwxr-xr-x  2 ckent  staff   68 27 Okt 13:35 guest

Status: Published Date: 2014-10-15 00:23:19 +0200 (Mi, 15 Okt 2014) Revision: 27

Copyright bei Andreas Haack (C) 2014. Diese Seite wird so wie sie ist zur Verfuegung gestellt, ohne irgenweche Garantien der Verwendbarkeit fuer bestimte Zwecke. Die auf dieser Seiten angebrachten Links liegen ausserhalb der redaktionellen Verantwortung von Andreas Haack und es wird keine Haftung oder Garantie uebernommen. Die Seiten sind Copyright (c) 2014 von Andreas Haack. Kein Teil darf ohne die schriftliche Einverstaendnis von Andreas Haack veroeffentlicht werden.
The page is provided 'as is' , without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fit- ness for a particular purpose and non-infringement. In no event shall Andreas Haack be liable for any claim, damages or other liability. This page is copyrighted property of Andreas Haack. Copyright by Andreas Haack (c) 2014 . No part of this page may be published without written permission for Andreas Haack. A hyper-link may created to this page but NOT to the embedded elements of this page. It may be freely downloaded for private purpose only as long as it is unaltered.