Gnu/coreutils/Sorting-the-output
Next: General output formatting, Previous: What information is listed, Up: ls invocation [Contents][Index]
10.1.3 Sorting the output
These options change the order in which ls sorts the information
it outputs. By default, sorting is done by character code
(e.g., ASCII order).
- ‘
-c’
‘--time=ctime’
‘--time=status’ If the long listing format (e.g.,
-l,-o) is being used, print the status change timestamp (the ctime) instead of the mtime. When explicitly sorting by time (--sort=timeor-t) or when not using a long listing format, sort according to the ctime. See File timestamps.- ‘
-f’ Primarily, like
-U—do not sort; list the files in whatever order they are stored in the directory. But also enable-a(list all files) and disable-l,--color, and-s(if they were specified before the-f).- ‘
-r’
‘--reverse’ Reverse whatever the sorting method is—e.g., list files in reverse alphabetical order, youngest first, smallest first, or whatever.
- ‘
-S’
‘--sort=size’ Sort by file size, largest first.
- ‘
-t’
‘--sort=time’ Sort by modification timestamp (mtime) by default, newest first. The timestamp to order by can be changed with the
--timeoption. See File timestamps.- ‘
-u’
‘--time=atime’
‘--time=access’
‘--time=use’ If the long listing format (e.g.,
--format=long) is being used, print the last access timestamp (the atime). When explicitly sorting by time (--sort=timeor-t) or when not using a long listing format, sort according to the atime. See File timestamps.- ‘
--time=birth’
‘--time=creation’ If the long listing format (e.g.,
--format=long) is being used, print the file creation timestamp if available. When explicitly sorting by time (--sort=timeor-t) or when not using a long listing format, sort according to the birth time. See File timestamps.- ‘
-U’
‘--sort=none’ Do not sort; list the files in whatever order they are stored in the directory. (Do not do any of the other unrelated things that
-fdoes.) This is especially useful when listing very large directories, since not doing any sorting can be noticeably faster.- ‘
-v’
‘--sort=version’ Sort by version name and number, lowest first. It behaves like a default sort, except that each sequence of decimal digits is treated numerically as an index/version number. (See Version sort ordering.)
- ‘
-X’
‘--sort=extension’ Sort directory contents alphabetically by file extension (characters after the last ‘
.’); files with no extension are sorted first.
Next: General output formatting, Previous: What information is listed, Up: ls invocation [Contents][Index]