home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / shell / 5453 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  1.1 KB

  1. Path: sparky!uunet!news.centerline.com!noc.near.net!hri.com!spool.mu.edu!yale.edu!ira.uka.de!smurf.sub.org!flatlin!bad
  2. From: bad@flatlin.ka.sub.org (Christoph Badura)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: Is there a "foreach" loop control in ksh?
  5. Message-ID: <C17nHu.6MA@flatlin.ka.sub.org>
  6. Date: 21 Jan 93 15:39:29 GMT
  7. References: <1304@alsys1.aecom.yu.edu>
  8. Organization: Guru Systems/Funware Department
  9. Lines: 25
  10.  
  11. In <1304@alsys1.aecom.yu.edu> manaster@yu1.yu.edu (Chaim Manaster) writes:
  12.  
  13. >I want to do a series of comands on each file in the current
  14. >directory, with some sort of "foreach" construct that will loop
  15. >over every file in some list (something like in perl), or in some
  16. >cases every file in the current directory. How would one do this in
  17. >ksh?
  18.  
  19. for variable in word...
  20. do
  21.   ...
  22. done
  23.  
  24. >In particular, I want to run compress on each file in the directory
  25. >that does not already end in a .Z  (dito for uncompress in
  26. >reverse).
  27.  
  28. compress `ls|egrep -v Z\$`
  29.  
  30.  
  31. -- 
  32.                 Christoph Badura  ---  bad@flatlin.ka.sub.org
  33.  
  34. Personally, I don't care whether someone is cool enough to quote Doug
  35. Gwyn--I only care whether Doug Gwyn is cool enough to quote. -- Larry Wall
  36.