Unix Command Line Options

Semicolon
; – Separates multiple commands on a command line and allows them to execute sequentially. The command “echo hello world ; date” gives the following output

hello world
Tue Jan 31 05:27:25 UTC 2012

Ampersand

& – Causes the preceding command to be run in the background

1) the command “echo hello world & date” gives

[1] 30528
hello world
Tue Jan 31 05:34:47 UTC 2012
[1]+  Done                    echo hello world

The first command “echo hello world” is spawned and sent to the background and given a job id of [1].

2) the command “echo hello world & date &” gives

[1] 30581
[2] 30582
hello world
Tue Jan 31 05:35:54 UTC 2012
[1]-  Done                    echo hello world
[2]+  Done                    date

The first command “echo hello world” is spawned and sent to the background and given a job id of [1].
The second command “date” is also spawned and set to the background and given a job id of [2].

Pipes

| Pipes the output of the command to the left of the pipe to the input of the command on the right of the pipe

The command “echo hello world | xargs printf “Found: %s\n”” gives
Found: hello
Found: world

 Greater than and Less Than

> Redirects output to a file or device
>> Appends output to a file

< Redirects input from a file or device

Round Brackets

() Launches commands enclosed in parentheses in a separate shell

    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s