home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / misc / 3508 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.5 KB  |  44 lines

  1. Newsgroups: comp.unix.misc
  2. Path: sparky!uunet!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news.mit.edu!jdell
  3. From: jdell@nefertiti.mit.edu (John Ellithorpe)
  4. Subject: Re: How to add a suffix to a bunch of files?
  5. In-Reply-To: dchin@tamar.msc.cornell.edu's message of Thu, 3 Sep 1992 21:36:46 GMT
  6. Message-ID: <JDELL.92Sep4152056@nefertiti.mit.edu>
  7. Sender: news@athena.mit.edu (News system)
  8. Nntp-Posting-Host: nefertiti.mit.edu
  9. Organization: Massachusetts Institute of Technology
  10. References: <1992Sep3.213646.26527@msc.cornell.edu>
  11. Date: Fri, 4 Sep 1992 20:20:56 GMT
  12. Lines: 30
  13.  
  14. On Thu, 3 Sep 1992 21:36:46 GMT, dchin@tamar.msc.cornell.edu (David W. Chin) said:
  15.  
  16. > I have occasion to add suffices on a whole bunch of files, like a .1 suffix on
  17. > all files in cat1 (just an example).  What's an elegant way to do it?
  18. > The one I thought of was:
  19.  
  20. > #!/bin/sh
  21. > cd cat1
  22. > for X in `ls -1`
  23. >     do
  24. >     eval "mv $X $X.1"
  25. >     done
  26.  
  27. If you are in some variant of csh, I personally use tcsh 6.02
  28.  
  29. % foreach file (*)
  30. foreach> mv $file $file.1
  31. foreach> end
  32.  
  33. And that's it.  Pretty much just as good as the Bourne shell version.
  34.  
  35. John
  36. --
  37.  
  38. ===============================================================================
  39. John Ellithorpe                           | Internet: jdell@maggie.mit.edu
  40. Dept. of Physics, Rm 26-349               | Phone   : (617) 253-3074  Office
  41. Massachusetts Institute of Technology     |           (617) 253-3072  Lab
  42. Cambridge, MA  02139                      |           (617) 236-4910  Home
  43. ===============================================================================
  44.