To list the contents of a directory use the ls command. The ls command issued alone, without specifying a directory, causes a listing of all subdirectories and non-hidden files in the current working directory to be displayed. By default files are listed in alphabetic order in a series of columns across the screen. Alternative ways of displaying directory contents can be specified by using command-line arguments to the ls command. One reason for providing arguments is that the default listing does not distinguish between subdirectories text files and other special files. To do this, use the -F option of the ls command:
ls -F
The resulting list of files denotes subdirectories with a trailing slash (`/') character, executable programs with a trailing asterisk (`*'), symbolic links with a trailing at-sign (`@'), and sockets with a trailing equals sign (`='). Hidden files, files beginning with a '.', are still not displayed; use the -a argument (for list all files) if you wish to list hidden files as well. To obtain specific information about files and directories, such as mode, size in bytes and time of last modification, use the -l argument with the ls command.
All of the various arguments available for use with any UNIX command can be combined into one character string for all arguments to take effect simultaneously, ie: ls -alFC. Full descriptions for all of the ls flags and options can be found under man ls .
The following aliases
are available to make the ls command more friendly:
ls [-options ] *.c
The asterisk 'wildcard' character matches any characters. To look for all files with the same name but different extensions, do a listing for <filename>.*.
Listing can be done on directories other than the current one by specifying a path to the directory after the listing options:
ls [-options]
/backup/*.c
This command would give a listing of all files with a .c extension in the subdirectory backup off of your home directory. For more information on WildCards see the C Shell Interface section on WildCards.