home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / misc / 3520 < prev    next >
Encoding:
Text File  |  1992-09-07  |  2.3 KB  |  58 lines

  1. Newsgroups: comp.unix.misc
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ais.org!umeecs!nova!ellis
  3. From: ellis@nova.gmi.edu (Stew Ellis)
  4. Subject: Re: How to add a suffix to a bunch of files?
  5. Message-ID: <ellis.715700967@nova>
  6. Sender: news@zip.eecs.umich.edu (Mr. News)
  7. Organization: GMI Engineering&Management Institute, Flint, MI
  8. References: <1992Sep3.213646.26527@msc.cornell.edu> <JDELL.92Sep4152056@nefertiti.mit.edu>
  9. Date: Sat, 5 Sep 1992 13:49:27 GMT
  10. Lines: 46
  11.  
  12. jdell@nefertiti.mit.edu (John Ellithorpe) writes:
  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.  
  45. (I hope Mr sef of the net bandwidth police doesn't jump my ass for including
  46. too much of the previous posters' messages) :-|
  47.  
  48. What is the point of the eval statement in the sh version?  I thought the
  49. point|advantage of using eval was to keep something in the context of the
  50. current shell.  I do not see why that is necessary here.  Is this cheaper
  51. somehow?  It seems much more straightforward to simply mv it rather than eval
  52. the mv, the way the csh example above does.
  53. --
  54. --                                                        ___________________
  55.   R.Stewart(Stew) Ellis, Assoc.Prof., (Off)313-762-9765  /   _____  ______ 
  56.   Humanities & Social Science,  GMI Eng.& Mgmt. Inst.   /        / /  /  / /
  57.   Flint, MI 48504      ellis@nova.gmi.edu              /________/ /  /  / /
  58.