home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / shell / 5460 < prev    next >
Encoding:
Text File  |  1993-01-22  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!nwnexus!ole!ssc!fyl
  3. From: fyl@ssc.com (Phil Hughes)
  4. Subject: Re: Is there a "foreach" loop control in ksh?
  5. Organization: SSC, Inc.,  Seattle, WA
  6. Date: Thu, 21 Jan 1993 23:07:57 GMT
  7. Message-ID: <1993Jan21.230757.21398@ssc.com>
  8. X-Newsreader: TIN [version 1.1 PL6]
  9. References: <8673@charon.cwi.nl>
  10. Lines: 30
  11.  
  12. Dik T. Winter (dik@cwi.nl) wrote:
  13. : In article <1993Jan19.173407.7128@cid.aes.doe.CA> afsypng@cid.aes.doe.CA (Jacques Marcoux) writes:
  14. :  > In article <1304@alsys1.aecom.yu.edu> manaster@yu1.yu.edu (Chaim Manaster) writes:
  15. :  > >In particular, I want to run compress on each file in the directory
  16. :  > >that does not already end in a .Z  (dito for uncompress in
  17. :  > >reverse).
  18. :  > >
  19. :  > Try
  20. :  >    for file in `ls *[!Z]`
  21. :  >    do
  22. :  >       compress $file
  23. :  >    done
  24. : Wrong for a few reasons:
  25. : 1. 'ls *[!Z]' will recurse through directories so change that to 'ls -d *[!Z]'.
  26. : 2. Why 'ls'?  Why not 'for file in *[!Z]'?
  27. : 3. This misses the file 'GLORKZ', which should be in the list.
  28. : For this particular question there is not a really satisfactory solution (but
  29. : I doubt there is one in csh). 
  30.  
  31. How about this?  Seems to 1) work, 2) be simple
  32.     for file in $(echo *.[^Z])
  33.         do
  34.         compress $file
  35.         done
  36. -- 
  37. Phil Hughes, SSC, Inc. P.O. Box 55549, Seattle, WA 98155  (206)FOR-UNIX
  38. >>> Publishers of pocket references for UNIX, C, VI, Emacs, Ksh, MS-DOS, ... <<<
  39.      ...!ssc!fyl or fyl@ssc.com            (206)527-3385
  40.  
  41.