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

  1. Newsgroups: comp.unix.misc
  2. Path: sparky!uunet!mcsun!Germany.EU.net!rz.uni-hildesheim.de!agsc!rubikon.han.de!toad
  3. From: toad@rubikon.han.de (Peter Cleve)
  4. Subject: Re: How to add a suffix to a bunch of files?
  5. Keywords: shell, script, files, names
  6. References: <1992Sep3.213646.26527@msc.cornell.edu>
  7. Organization: Rubikon Rethen BRD
  8. Date: Sat, 05 Sep 92 17:18:05 GMT
  9. Message-ID: <1992Sep05.171805.4769@rubikon.han.de>
  10. Lines: 30
  11.  
  12. In <1992Sep3.213646.26527@msc.cornell.edu> dchin@tamar.msc.cornell.edu (David W. Chin) writes:
  13.  
  14. >I have occasion to add suffices on a whole bunch of files, like a .1 suffix on
  15. >all files in cat1 (just an example).  What's an elegant way to do it?
  16. >The one I thought of was:
  17.  
  18. >#!/bin/sh
  19. >cd cat1
  20. >for X in `ls -1`
  21. >    do
  22. >    eval "mv $X $X.1"
  23. >    done
  24.  
  25. How about
  26.  
  27.     for i in *; do
  28.         mv "$i" "$i.1"
  29.     done
  30.  
  31. or (with arguments)
  32.  
  33.     for i in $@; do
  34.         mv "$i" "$i.1"
  35.     done
  36.  
  37. By
  38.  
  39. -- 
  40. Peter Cleve, Hildesheimer Str. 316, 3014 Laatzen 3, Tel. 05102/1854 (Voice)
  41.   Energiesparen ist das moralische Aequivalent zum Krieg. (Jimmy Carter)
  42.