Tuesday, October 9, 2012

Unix in a nut shell-1


1) Getting the Absolute Path in the shell script:

scriptFile=$(readlink -fn $(type -p $0))
echo "Absolute path: $scriptFile"

1) Reading ALL the command-line params in the shell script:

Shell script accepts parameters in following format... 
$1 : first 
$2 : second....so on upto  9th param,
$9 : 9th param 

whereas $0 : gives script/function name 

If your script has more than 9 params then !???? :( :( 

No worries ... just access them in following way... 
${12} : 12th param 
${18} : 18th param

No comments:

Post a Comment