cd ~/it244/ex
mkdir ex18
cd ex18
ps -f
The -f option to ps gives you more information about running processes.| UID | The username of the account that started the process |
| PID | The process ID |
| PPID | The process ID of the parent process |
| STIME | When the process started |
| CMD | The command line that started the process |
ps
sleep 120 & ps -f
Notice that the process ID of the parent process that called sleep and ps -f is
the process ID of your shell.pstree while several sleep processes are running
sleep 20 & sleep 20 & pstree -ph
Look at the bold line of processes, which denotes your shell. You will
notice sleep processes running under your bash shell.
cp ~tsoro/course_files/it244_files/print_positionals.sh .
cat print_positionals.sh
The script simply prints the first four tokens on the command line.
./print_positionals.sh foo bar bletch
Notice that the first positional parameter printed, 0, is the name
of the command.
cp ~tsoro/course_files/it244_files/print_arg_numbers.sh .
cat print_arg_numbers.sh
./print_arg_numbers.sh foo bar bletch
The script prints the number of arguments given to it on the command line.
city=Boston
echo $city
city='New York'
echo $city
big_apple='$city $city'
echo $big_apple
Single quotes do not allow you to get the value of a variable.
big_apple="$city $city"
echo $big_apple
This time it works, because you can use the value of a variable inside double quotes.
city=Boston ; state=MA
echo $city ; echo $state
unset
unset city
echo $city
city now has no value.
state=
echo $state
Now state has no value.
team=Patriots
echo $team
team="Red Sox"
echo $team
declare -r team
team=Celtics
You can't change the value because team is now read only.
cd ~/it244/ex/ex18
nano ex18.sh
chmod 755 ex18.sh
bash ex18.sh > /dev/null
~tsoro/it244_test/ex18.sh
When the script asks if you are ready for more, hit Return or Enter.