O'Reilly logo

Unix in a Nutshell, 4th Edition by Arnold Robbins

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

ls

Synopsis

    ls [options] [names]

If no names are given, list the files in the current directory. With one or more names, list files contained in a directory name or that match a file name. The options let you display a variety of information in different formats. The most useful options include -F, -R, -a, -l, and -s. Some options don't make sense together; e.g., -u and -c.

Tip

Modern versions of ls pay attention to the LC_COLLATE environment variable. Its default value, en_US, (in the United States) causes ls to sort in dictionary order (i.e., ignoring case). You may prefer to set LC_COLLATE to C to restore the traditional Unix behavior of sorting in ASCII order.

Common Options

-a, --all

List all files, including the normally hidden . files.

-A, --almost-all

Like -a, but exclude . and .. (the current and parent directories).

-b, --escape

Show nonprinting characters in octal.

-c, --time-ctime, --time=status

List files by inode modification time.

-C, --format=vertical

List files in columns (the default format, when displaying to a terminal device).

-d, --directory

List only the directory's information, not its contents. (Most useful with -l and -i.)

-f

Interpret each name as a directory (files are ignored).

-F, --classify, --indicator-style=classify

Flag filenames by appending / to directories, > to doors (Solaris only), * to executable files, | to FIFOs, @ to symbolic links, and = to sockets.

-g

Like -l, but omit owner name (show group).

-h

Produce "human-readable" output, using abbreviations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required