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

 About This Book

 2002 - .NET Framework Developed by Microsoft

 1995 - PHP: Hypertext Preprocessor Created by Rasmus Lerdorf

 1995 - Java Language Developed by Sun Microsystems

 1991 - WWW (World Wide Web) Developed by Tim Berners-Lee

 1991 - Gopher Protocol Created by a University of Minnesota Team

 1984 - X Window System Developed a MIT Team

 1984 - Macintosh Developed by Apple Inc.

 1983 - "Sendmail" Mail Transfer Agent Developed by Eric Allman

 1979 - The Tcsh (TENEX C Shell) Developed by Ken Greer

 1978 - Bash (Bourne-Again Shell) Developed by Brian Fox

 1978 - The C Shell Developed by Bill Joy

1977 - The Bourne Shell Developed by Stephen Bourne

 What Is the Bourne Shell

 Bourne Shell Command Line Examples

Bourne Shell Script File Examples

 1977 - Apple II Designed by Steve Jobs and Steve Wozniak

 1976 - vi Text Editor Developed by Bill Joy

 1974 - Internet by Vinton Cerf

 1972 - C Language Developed by Dennis Ritchie

 1971 - FTP Protocol Created by Abhay Bhushan

 1970 - UNIX Operating System Developed by AT&T Bell Labs

 1957 - FORTRAN Language Developed by IBM

 References

 Full Version in PDF/EPUB