WinUtils - ls

Download now!


ls - lists the contents of a directory


ls [-1acdfhklqrstuxCFRSTZ?] [file...]


For each file that is a directory, ls lists the contents of the directory. For each file that is an ordinary file, ls repeats its name and any other information requested. The output is sorted aphabetically by default. When no argument is given, the current directory is listed. When several arguments are given, then the arguments are first sorted appropriately, but file arguments appear before directories and their contents.

There are three major listing formats:


-a List all entries, even those starting with '.'.
-c Use the creation date for date output.
-C Column format - the output is formed up into as many columns that will fit in the terminal column width. This is the default output when the output is to a terminal.
-d List directory name, not contents.
-f The output is not sorted.
-F Display the file type. The file name is prepended with a '-' if it is a directory, a '*' if it is executable, and '@' if it is a link.
-k The file size is output in kbytes.
-l Long format (see below).
-q Quite. No output is printed for empty directories.
-r Reverse the sort.
-R Recurse through all child directories.
-s Sort by file size.
-S Display file size.
-t Sort by file time.
-T Display full time format.
-u Use the last-used time.
-x Sort by extension.
-Z Print totals.
-1 Single column format. This forces the output to be one line per entry per line. This is the default format for non-terminal output.
file The path of the input file.

The -1, -C, and -l options are mutually exclusive; the last one specified determines the format used.

The long format

If the -l option is given, the following information is displayed for each file: file attributes, file size, file date, and the path- name. In addition, for each directory, the total number files, directories, and entries are displayed, together with the total byte count.

If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.

The file attributes consists of a five character string - dshra, where...

d directory entry
s system file
h hidden file
r read-only
a archive bit