home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!nucsrl!ddsw1!dattier
- From: dattier@ddsw1.mcs.com (DWT)
- Subject: Re: Is there a "foreach" loop control in ksh?
- Message-ID: <C19v3B.6pH@ddsw1.mcs.com>
- Date: Fri, 22 Jan 1993 20:18:47 GMT
- References: <1304@alsys1.aecom.yu.edu>
- Organization: Contributor Account at ddsw1, Chicago, Illinois 60657
- Lines: 25
-
- manaster@yu1.yu.edu (Chaim Manaster) wrote in <1304@alsys1.aecom.yu.edu>:
-
- | I want to do a series of comands on each file in the current
- | directory, with some sort of "foreach" construct that will loop
- | over every file in some list (something like in perl), or in some
- | cases every file in the current directory. How would one do this in
- | ksh?
-
- for variable in list
- do commands
- done
-
- | 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).
-
- There's no need for a for loop to call compress or uncompress separately for
- each file, since both can take a number of filenames as arguments.
-
- compress !(*.Z)
- # in older ksh versions, compress *[!Z] *[!.]Z
- uncompress *.Z
-
- David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297
- dattier@ddsw1.mcs.com CompuServe: 73720,1570 MCI Mail: 426-1818
-