Linux Shell Scripting Tutorial
Introduction Tools required for shell scripting First shell script Interacting with user Operators Special characters in BASH scripting Variables in Linux BASH scripting Arrays Integer operations floating point operations String manipulation in shell scripting Parameter substitution Command Substitution Conditional statements Looping statements Passing parameters exit status of the script Functions Sourcing filespassing arguments in linux shell scripting
We can pass the parameters (arguments) to shell script delimited by white spaces. You can access the current script name and arguments using $0, $1,$2….and so on.- $0 = Script name (also called as base name of file)
- $1 = First argument to the script
- $2 = Second argument to the script and so on..
if [ $# < 2 ]
then
echo “Count of parameters is less than 2”
exit -1
fi
We can use below special variables to access the parameters.- $@ – All of the arguments.
- $* – All of the arguments. This does not preserve the white space and quotes.
- $$ – This gives you the process id of current shell.
- $! – This gives you the process id of last background process.
Web development and Automation testing
solutions delivered!!