home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.misc
- Path: sparky!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news.mit.edu!jdell
- From: jdell@nefertiti.mit.edu (John Ellithorpe)
- Subject: Re: How to add a suffix to a bunch of files?
- In-Reply-To: dchin@tamar.msc.cornell.edu's message of Thu, 3 Sep 1992 21:36:46 GMT
- Message-ID: <JDELL.92Sep4152056@nefertiti.mit.edu>
- Sender: news@athena.mit.edu (News system)
- Nntp-Posting-Host: nefertiti.mit.edu
- Organization: Massachusetts Institute of Technology
- References: <1992Sep3.213646.26527@msc.cornell.edu>
- Date: Fri, 4 Sep 1992 20:20:56 GMT
- Lines: 30
-
- 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
- ===============================================================================
-