home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.misc
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ais.org!umeecs!nova!ellis
- From: ellis@nova.gmi.edu (Stew Ellis)
- Subject: Re: How to add a suffix to a bunch of files?
- Message-ID: <ellis.715700967@nova>
- Sender: news@zip.eecs.umich.edu (Mr. News)
- Organization: GMI Engineering&Management Institute, Flint, MI
- References: <1992Sep3.213646.26527@msc.cornell.edu> <JDELL.92Sep4152056@nefertiti.mit.edu>
- Date: Sat, 5 Sep 1992 13:49:27 GMT
- Lines: 46
-
- jdell@nefertiti.mit.edu (John Ellithorpe) writes:
-
- >On Thu, 3 Sep 1992 21:36:46 GMT, dchin@tamar.msc.cornell.edu (David W. Chin) said:
-
- >> I have occasion to add suffices on a whole bunch of files, like a .1 suffix on
- >> all files in cat1 (just an example). What's an elegant way to do it?
- >> The one I thought of was:
-
- >> #!/bin/sh
- >> cd cat1
- >> for X in `ls -1`
- >> do
- >> eval "mv $X $X.1"
- >> done
-
- >If you are in some variant of csh, I personally use tcsh 6.02
-
- >% foreach file (*)
- >foreach> mv $file $file.1
- >foreach> end
-
- >And that's it. Pretty much just as good as the Bourne shell version.
-
- >John
- >--
-
- >===============================================================================
- >John Ellithorpe | Internet: jdell@maggie.mit.edu
- >Dept. of Physics, Rm 26-349 | Phone : (617) 253-3074 Office
- >Massachusetts Institute of Technology | (617) 253-3072 Lab
- >Cambridge, MA 02139 | (617) 236-4910 Home
- >===============================================================================
-
- (I hope Mr sef of the net bandwidth police doesn't jump my ass for including
- too much of the previous posters' messages) :-|
-
- What is the point of the eval statement in the sh version? I thought the
- point|advantage of using eval was to keep something in the context of the
- current shell. I do not see why that is necessary here. Is this cheaper
- somehow? It seems much more straightforward to simply mv it rather than eval
- the mv, the way the csh example above does.
- --
- -- ___________________
- R.Stewart(Stew) Ellis, Assoc.Prof., (Off)313-762-9765 / _____ ______
- Humanities & Social Science, GMI Eng.& Mgmt. Inst. / / / / / /
- Flint, MI 48504 ellis@nova.gmi.edu /________/ / / / /
-