home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / question / 10246 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.3 KB  |  47 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!usc!rpi!fitzgb
  3. From: fitzgb@mml0.meche.rpi.edu (Brian Fitzgerald)
  4. Subject: Re: Changing file names
  5. Message-ID: <g1hy6sd@rpi.edu>
  6. Nntp-Posting-Host: mml0.meche.rpi.edu
  7. Organization: Rensselaer Polytechnic Institute, Troy, NY
  8. References: <ac#n06l.bosak@netcom.com>
  9. Date: Fri, 21 Aug 1992 06:07:57 GMT
  10. Lines: 35
  11.  
  12. Jon Bosak writes:
  13. >
  14. >Suppose I have a directory containing files named, for example,
  15. >
  16. >      xyz920815a ...
  17. >
  18. >...and so on.  I want to change the names of these files to
  19. >
  20. >      920815a ...
  21.  
  22. A wise system programmer at RPI decided that the campus user shell will
  23. be bash, regardless of the vendor platform (thanks, Scanner!).  A bash
  24. solution (like the ksh solution posted by someone else.) is
  25.  
  26. for i in xyz* ; do mv $i ${i#xyz} ; done
  27.  
  28. To me, this is simple enough to type from memory without using aliases
  29. or shell scripts.
  30.  
  31. For testing, I usually type
  32.  
  33. for i in xyz* ; do echo mv $i ${i#xyz} ; done
  34.  
  35. and look at the echo output.  If it looks ok, I type ^echo to actually
  36. run the command.  On the other hand, if the echo prints something
  37. unexpected, I just press the uparrow key, edit the command line, and
  38. try again.
  39.  
  40. To changes suffixes, instead of prefixes, try, for example,
  41.  
  42. for i in *.c ; do mv $i ${i%.c}.o ; done
  43.  
  44. Bash is available for free from lots of places.  Check archie.
  45.  
  46. Brian
  47.