Listing Files

You can use the ls command to list the filenames in either the current directory or a different directory. The following is the general syntax:

ls options arg1 arg2 ...

Here, options may be -l (as you saw earlier) or many other options, as described in later sections. arg1 arg2 are file or directory names to be listed.

If a directory is given, then the contents of the directory will be shown (unless the -d option is present). If no arguments are given, the contents of the current directory will be shown.

See Table 7.3 for other standard properties of the ls command.

Table 7.3. Other Properties of the ls Command
PropertySee page
Allows relative and absolute pathname arguments70
Allows a list of filenames and filename wildcards292
Allows ...

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.