Computer History - Herong's Notes - Version 3.11, by Dr. Herong Yang
Bourne Shell Script File Examples
This section provides some Bourne shell command line examples with explanations.
The Bourne shell supports executable script files, which are collections of Bourne command lines stored in text files. When a script file is executed, all command lines in the script file will be executed in the same order they appear in the file.
Here is a Bourne shell script file, f, which uses 3 command programs to print information about the specified file:
#!/bin/sh # f name echo echo File list info: ls -l $1 # list file info echo echo Numer of lines: wc -1 $1 # count words in this file echo echo File type: file $1
If the Bourne shell is defined as the starting shell after login, it will run the .profile script file in the home directory to initialize the environment. Here is a simple example of .profile script file:
# .profile PATH=$PATH:$HOME/bin:. # set command search path MAIL=/usr/spool/mail/`logname` # mailbox location export PATH MAIL who # see who is using the system
Table of Contents