cd ~/it244/ex
mkdir ex19
cd ex19
ps -fThe -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 |
pssleep 120 & ps -fNotice 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 runningsleep 20 & sleep 20 & pstree -phLook at the bold line of processes, which denotes your shell. You will notice sleep processes running under your bash shell.
cp ~ghoffman/course_files/it244_files/print_positionals.sh .
cat print_positionals.shThe script simply prints the first four tokens on the command line.
./print_positionals.sh foo bar bletchNotice that the first positional parameter printed, 0, is the name of the command.
cp ~ghoffman/course_files/it244_files/print_arg_numbers.sh .
cat print_arg_numbers.sh
./print_arg_numbers.sh foo bar bletchThe 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_appleSingle quotes do not allow you to get the value of a variable.
big_apple="$city $city"
echo $big_appleThis time it works, because you can use the value of a variable inside double quotes.
cd ~/it244/ex/ex19
nano ex19.sh
chmod 755 ex19.sh
bash ex19.sh > /dev/null
~ghoffman/it244_test/ex19.shWhen the script asks if you are ready for more, hit Return or Enter.