Next: Simple test script
Up: More shell script examples
Previous: More shell script examples
Suppose, you want a command called print that expands tabs to four spaces and
then prints it on the default printer. The program expand -4 expands tabs
to 4 spaces. So we create a file called print that contains the
expand -4 $1 | lpr
Here $1 denotes the first command line argument passed to the script
print, the name of the file to print. Then we set the executable bit
and move the print script to our bin directory.
chmod +x print
mv print ~/bin/
Now we have the print command available from anywhere.