ls - It's not just for breakfast anymore!
ls is one of the most frequently used UNIX utilities. It's
also one of the utilities which is least fully utilized. Some
versions of ls have so many options that there are only a
few characters which aren't options. ls will burn
your eggs and scramble your toast if you know how to tell it to.
From the top of the GNU ls manpage:
NAME
ls, dir, vdir - list contents of directories
SYNOPSIS
ls [-abcdefgiklmnopqrstuxABCFGLNQRSUX178] [-w cols] [-T
cols] [-I pattern] [--all] [--escape] [--directory]
[--inode] [--kilobytes] [--numeric-uid-gid] [--no-group]
[--hide-control-chars] [--reverse] [--size] [--width=cols]
[--tabsize=cols] [--almost-all] [--ignore-backups]
[--classify] [--file-type] [--full-time]
[--ignore=pattern] [--dereference] [--literal] [--quote-
name] [--recursive] [--sort={none,time,size,extension}]
[--format={long,verbose,commas,across,vertical,single-col-
umn}] [--time={atime,access,use,ctime,status}]
[--color[={yes,no,tty}]] [--colour[={yes,no,tty}]]
[--7bit] [--8bit] [--help] [--version] [name...]
If you're not scared now, you should be.
It's probably a Good Idea(tm) to look through the ls
manpage on any system you use frequently. Some of the more common
options are listen below.
- -a
- Also list files which start with a '.' character. By convention,
these files are normally not listed.
- -d
- List a directory itself, rather than its contents.
- -g and -l
- BSD and System V Unices differ with respect to these flags.
-l is for long output format, which includes file
permissions, owner, size, date, and name of each file. -g
is for listing the group a file is in. Under BSD, specifying
-l without -g does not give you the file's
group; specifying both gives you all of the information. Under System
V, specifying -l gives you all the info by itself; also
specifying -g supresses printing of the owner and prints
only the group of the file. Here is an example of the long
output format:
-rw------- 1 roth student 5330 Jan 25 1994 dynamic.xbm
- -t
- Sort listing by time of files instead of alphabetically.
- -1
- Print one filename per line.
- -F
- Use special characters to indicate file type. If the file is a
directory, append a / to the filename. If the file is an
executable, append a * to the filename. If the file is a symbolic
link, append a @.
- -R
- Recursively descend directories.
Mark D. Roth (roth@uiuc.edu)