home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9418 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  920 b 

  1. Path: sparky!uunet!gatech!purdue!hsdndev!news.cs.umb.edu!mzraly
  2. From: mzraly@ra.cs.umb.edu (Michael S. Zraly)
  3. Newsgroups: comp.unix.questions
  4. Subject: Bourne shell read command
  5. Message-ID: <1992Jul24.213654.29656@cs.umb.edu>
  6. Date: 24 Jul 92 21:36:54 GMT
  7. Sender: news@cs.umb.edu (USENET News System)
  8. Organization: UMass/Boston Dept. of Math & CS
  9. Lines: 29
  10.  
  11.  
  12. I am looking to read a file containing lines of the form
  13.  
  14.     field1    field2    field3
  15.  
  16. from a shell file, setting the variables mac to field2 and
  17. dir to field3 if field1 matches the variable abbrev.
  18.  
  19. The following code does NOT work, but illustrates my meaning:
  20.  
  21.     # this does NOT work
  22.     while (read x y z junk < $afile)
  23.     do
  24.         if test $x = $abbrev
  25.         then
  26.             mac=$y        # 'export mac' doesn't help
  27.             dir=$z
  28.         fi
  29.     done
  30.  
  31. Does anyone have any ideas?
  32.  
  33. Thanks,
  34.   Mike
  35.  
  36.  
  37. -- 
  38. Mike Zraly        Never attribute to malice that which
  39. mzraly@cs.umb.edu    is adequately explained by stupidity.
  40.