OnWorks Linux and Windows Online WorkStations

Logo

Free Hosting Online for WorkStations

< Previous | Contents | Next >

Options And Arguments

This brings us to a very important point about how most commands work. Commands are often followed by one or more options that modify their behavior, and further, by one or more arguments, the items upon which the command acts. So most commands look kind of like this:



command -options arguments

command -options arguments


Most commands use options consisting of a single character preceded by a dash, for ex- ample, “-l”, but many commands, including those from the GNU Project, also support long options, consisting of a word preceded by two dashes. Also, many commands allow multiple short options to be strung together. In this example, the ls command is given two options, the “l” option to produce long format output, and the “t” option to sort the result by the file's modification time.



[me@linuxbox ~]$ ls -lt

[me@linuxbox ~]$ ls -lt

More Fun With ls


We'll add the long option “--reverse” to reverse the order of the sort:



[me@linuxbox ~]$ ls -lt --reverse

[me@linuxbox ~]$ ls -lt --reverse


image

Note that command options, like filenames in Linux, are case-sensitive.


image

The ls command has a large number of possible options. The most common are listed in Table 3-1.


Table 3- 1: Common ls Options


Option

Long Option

Description

-a

--all

List all files, even those with names that begin

with a period, which are normally not listed

(i.e., hidden).

-A

--almost-all

Like the -a option above except it does not

list . (current directory) and .. (parent

directory).

-d

--directory

Ordinarily, if a directory is specified, ls will

list the contents of the directory, not the

directory itself. Use this option in conjunction

with the -l option to see details about the

directory rather than its contents.

-F

--classify

This option will append an indicator character

to the end of each listed name. For example, a

“/” if the name is a directory.

-h

--human-readable

In long format listings, display file sizes in

human readable format rather than in bytes.

-l

Display results in long format.

-r

--reverse

Display the results in reverse order. Normally,

ls displays its results in ascending

alphabetical order.

-S

Sort results by file size.

-t

Sort by modification time.


Top OS Cloud Computing at OnWorks: