Special shell variables : Unix/Linux

Special shell variables  There are some variables which are set internally by the shell and which are available to the user:

Name Description
$1 – $9 these variables are the positional parameters.
$0 the name of the command currently being executed.
$# the number of positional arguments given to this invocation of the shell.
$? the exit status of the last command executed is given as a decimal string.  When a command impletes successfully, it returns the exit status of 0 (zero), otherwise it returns a non-zero exit status
$$             the process number of this shell – useful for including in filenames, to make them unique.
$!            the process id of the last command run in the background.
$-            the current options supplied to this invocation of the shell.
$* a string containing all the arguments to the shell, starting at $1.
$@  same as above, except when quoted.

Tips ::
$* and $@ when unquoted are identical and expand into the arguments.
“$*” is a single word, comprising all the arguments to the shell, joined together with spaces. For example ‘1 2’ 3 becomes “1 2 3”.
“$@” is identical to the arguments received by the shell, the resulting list of words completely match what was given to the shell. For example ‘1 2’ 3 becomes “1 2” “3”..
 
 

njoy the simplicity…….
©Victimizeit

Advertisements

About victimizeit
This is Atul.. working for IBM as a DataStage Developer. I may not be an expert on any particular DataStgae technology, but I'm sure I do know a few things about DB2, AIX, Unix, Windows, and DataBase. In this blog, I'll give out some tips on these subjects. If you find them useful, great, I'll be happy. Thanks for stopping by !!

What is your opinion ?

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

%d bloggers like this: