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