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

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!gatech!rpi!psinntp!psinntp!dg-rtp!hobbit!hunt
  3. From: hunt@dg-rtp.rtp.dg.com (Greg Hunt)
  4. Subject: Re: Changing file names
  5. Message-ID: <1992Aug20.202625.16938@dg-rtp.dg.com>
  6. Sender: hunt@hobbit (Greg Hunt)
  7. Date: Thu, 20 Aug 92 20:26:25 GMT
  8. Reply-To: hunt@dg-rtp.rtp.dg.com
  9. References:  <ac#n06l.bosak@netcom.com>
  10. Organization: Data General Corp., Research Triangle Park, NC
  11. Lines: 39
  12.  
  13. In article <ac#n06l.bosak@netcom.com>, bosak@netcom.com (Jon Bosak) writes:
  14. > Here's a problem that must be very common but doesn't seem to get
  15. > discussed in books for Unix novices.
  16. > Suppose I have a directory containing files named, for example,
  17. >       xyz920815a
  18. >       xyz920815b
  19. >       xyz920816
  20. >       xyz920817
  21. >       xyz920818a
  22. >       xyz920818b
  23. > ...and so on.  I want to change the names of these files to
  24. >       920815a
  25. >       920815b
  26. >       920816
  27. >       920817
  28. >       920818a
  29. >       920818b
  30. > ...and so on.  Simple, right?  Just chop off the first three
  31. > characters and there you are.  But how is it done?
  32.  
  33. Here's one way:
  34.  
  35. #!/bin/sh
  36. for Tmp in xyz*
  37. do
  38.     mv $Tmp `echo $Tmp | awk '{print substr ($1, 4)}'`
  39. done
  40.  
  41. -- 
  42. Greg Hunt                            email: hunt@dg-rtp.rtp.dg.com
  43. DG/UX Core Development
  44. Data General Corporation
  45. Research Triangle Park, NC, USA      These opinions are mine, not DG's.
  46.