Sunday, 5 June 2005

Special shell variables used in shell scripts

These are the special shell variables which can be used in shell scripts in Linux.

$# The number of arguments.
$@ All arguments, as separate words.
$* All arguments, as one word.
$$ ID of the current process.
$? Exit status of the last command.
$0,$1,..$9,${10},${11}…${N} Positional parameters. After “9″ you must use the ${k} syntax.


For example, if you create a shell script as follows :

#!/bin/sh
#File: test.sh
echo $$
Now if you execute it, then you will find that it will print the program 'test.sh' process ID.

No comments:

Post a Comment