bashdoes not see the variable foo followed by the string "bar".
echo $$The value returned by $$ is the process ID of your current shell.
echo $?The command returns 0 since the previous command executed successfully.
echo $?The command returns 2 indicating that the previous command failed.
sleep 120 &
echo $!The number returned is the same as the PID that appeared on the command line when the background job was created.
nanoor an editor of your choice, create the script positionals.sh
chmod 755 positionals.sh
./positionals.sh foo bar bletchYou should see
This shell script was called using ./positionals.sh This shell script was called using 3 command line arguments Here are the command line arguments: foo bar bletch Positional parameter 1: foo Positional parameter 2: bar Positional parameter 3: bletch
nano, or an editor of your choice, create the following shell script shift.sh
chmod 755 shift.sh
./shift.sh foo bar bletchYou should see
foo bar bletchThe
shiftcommand moves each command line argument in turn into the first positional parameter, allowing us to print each argument until there are no more command line arguments left.
nano, or an editor of your choice, create the following shell script set.sh
chmod 755 set.sh
./set.shYou should see
Here are the arguments given to this script: After calling set Positional parameter 1: foo Positional parameter 2: bar Positional parameter 3: bletchEven though no arguments were given to the script at the command line,
setcreated these arguments from within the script.