Example script: ex2.sh


   1: #!/bin/sh
   2: # Find an entry in the password file
   3: pwent=`grep '^root:' /etc/passwd`
   4: # Turn off globbing - passwd lines often contain '*'
   5: set -o noglob
   6: # The "full name" and other comments are in
   7: # field 5, colon delimited.  Get this field using shell word splitting
   8: OIFS=$IFS; IFS=: ; set $pwent; IFS=$OIFS
   9: echo $5



  last modified 22/03/2012 Introduction Table of Contents
(frame/no frame)
Printable
(single file)
© Dartmouth College