




Command:   sh - shell
Syntax:    sh [file]
Flags:     (none)
Example:   sh < script              # Run a shell script

     Sh is the shell.  It  permits  redirection  of  input  and  output,
pipes, magic characters, background processes, shell scripts and most of
the other features of the V7 (Bourne) shell.  A few of the  more  common
commands are listed below:

   date                    # Regular command
   sort <file              # Redirect stdin
   sort <file1  >file2     # Redirect stdin and stdout
   cc file.c  2>error      # Redirect stderr
   a.out >f  2>&1          # Combine standard output and standard error
   sort <file1  >>file2    # Append output to file2
   sort <file1  >file2 &   # Background job
   (ls -l; a.out) &        # Run two background commands sequentially
   sort <file | wc         # Two-process pipeline
   sort <f | uniq | wc     # Three-process pipeline
   ls -l *.c               # List all files ending in .c
   ls -l [a-c]*            # List all files beginning with a, b, or c
   ls -l ?                 # List all one-character file names
   ls \?                   # List the file whose name is question mark
   ls '???'                # List the file whose name is three  question
   marks
   v=/usr/ast              # Set shell variable v
   ls -l $v                # Use shell variable v
   PS1='Hi! '              # Change the primary prompt to Hi!
   PS2='More: '            # Change the secondary prompt to More:
   ls -l $HOME             # List the home directory
   echo $PATH              # Echo the search path
   if ... then ... else ... fi # If statement
   for ... do ... done     # Iterate over argument list
   while ... do ... done   # Repeat while condition holds
   case ... in ...  esac   # Select clause based on condition
   echo $?                 # Echo exit status of previous command
   echo $$                 # Echo shell's pid
   echo $#                 # Echo number of parameters (shell script)
   echo $2                 # Echo second parameter (shell script)
   echo $*                 # Echo all parameters (shell script)

















                                                                        

