Tuesday, August 24, 2010

Programming in Unix Environment : Using the shell

Command line structure :

A command usually ends with a newline but a semicolon ';' is also a command terminator. Parentheses can be used to group commands. Data flowing through a pipe can be trapped and placed in a file by using 'tee' command. tee copies its input to the file and its output. Another command terminator is '&' ampersand, which tells the shell not to wait for the command to complete, and we can enter another command to execute. The 'sleep' command waits the specified number of seconds before exiting. Here shows an example in which the the command after ampersand is 'who' it executes first and date executes after five seconds.

$ (date ; who) | wc
$ (who ; date) | tee file | wc
$ long-running-command &
$ sleep 5
$ (sleep 5 ; date) & who

Metacharacters :

The way to specify the metacharacters without its meaning - within single quotes.

$ echo '**'

No comments:

Post a Comment