home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10261 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.5 KB

  1. Path: sparky!uunet!dtix!darwin.sura.net!convex!convex!tchrist
  2. From: tchrist@convex.COM (Tom Christiansen)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Changing file names
  5. Message-ID: <1992Aug21.135128.20589@news.eng.convex.com>
  6. Date: 21 Aug 92 13:51:28 GMT
  7. References: <ac#n06l.bosak@netcom.com> <31810002@hpcuhe.cup.hp.com>
  8. Sender: usenet@news.eng.convex.com (news access account)
  9. Reply-To: tchrist@convex.COM (Tom Christiansen)
  10. Organization: Convex Computer Corporation, Colorado Springs, CO
  11. Lines: 35
  12. Originator: tchrist@pixel.convex.com
  13. Nntp-Posting-Host: pixel.convex.com
  14. X-Disclaimer: This message was written by a user at CONVEX Computer
  15.               Corp. The opinions expressed are those of the user and
  16.               not necessarily those of CONVEX.
  17.  
  18. From the keyboard of srini@hpcuhe.cup.hp.com (Sreenivasa R Tellakula[C]):
  19. :following script should be able to change file names
  20. :
  21. :#!/bin/ksh
  22.  
  23. The 'k' above is superfluous.  If you're going to use 
  24. ksh, use its special syntax for this, like
  25.  
  26.      for file in xyz* ; do
  27.     mv $file ${file#xyz}
  28.      done
  29.  
  30. :for i in `ls`
  31. :do
  32. :  echo $i | sed s/xyz// >j
  33. :  mv $i `cat j`
  34. :done
  35. :rm j
  36.  
  37. Process pig.  Why not
  38.  
  39.     mv $i `echo $i | sed 's/^xyz//'`
  40.  
  41. Also, your method is going to earn you a lot of
  42.  
  43.     mv: foo and foo are identical
  44.  
  45. errors.
  46.  
  47. --tom
  48. -- 
  49.     Tom Christiansen      tchrist@convex.com      convex!tchrist
  50.  
  51.     "UNIX was not designed to stop you from doing stupid things, because
  52.      that would also stop you from doing clever things." -- Doug Gwyn
  53.