December 2012
Intermediate to advanced
888 pages
48h 24m
English
For example, if a shell program mypgm expects two parameters—such as a first name and a last name—you can invoke the shell program with only one parameter, the first name. However, you cannot invoke it with only the second parameter, the last name.
Here is a shell program called mypgm1, which takes only one parameter (a name) and displays it on the screen:
#!/bin/sh#Name display programif [ $# -eq 0 ] then echo "Name not provided"else echo "Your name is "$1fi
If you execute mypgm1, as follows
matthew@seymour:~$ bash mypgm1
you get the following output:
Name not provided
However, if you execute mypgm1, as follows
matthew@seymour:~$ bash mypgm1 Heather
you get the this output:
Your name is Heather ...
Read now
Unlock full access