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

  1. Path: sparky!uunet!mcsun!sunic!chalmers.se!biorn
  2. From: biorn@phc.chalmers.se (Bjorn Sandell)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: Changing file names
  5. Message-ID: <13549@chalmers.se>
  6. Date: 20 Aug 92 08:41:29 GMT
  7. References: <ac#n06l.bosak@netcom.com>
  8. Sender: news@chalmers.se
  9. Organization: Dep. of Phys. Chem.   Univ. of Gothenburg   Sweden
  10. Lines: 29
  11.  
  12. In article <ac#n06l.bosak@netcom.com>, bosak@netcom.com (Jon Bosak) writes:
  13. |> 
  14. |> Here's a problem that must be very common but doesn't seem to get
  15. |> discussed in books for Unix novices.
  16. |> 
  17. |> Suppose I have a directory containing files named, for example,
  18. |> 
  19. |>       xyz920815a
  20. |>       xyz920815b
  21. |>       xyz920816
  22. |> 
  23. |> ...and so on.  I want to change the names of these files to
  24. |> 
  25. |>       920815a
  26. |>       920815b
  27. |>       920816
  28. |> 
  29. |> Who can provide the most elegant solution using just the basic Unix 
  30. |> tools (cp, mv, sed, awk, sh, csh)?
  31.  
  32.  
  33. Why not use ksh? 
  34.  
  35.  for file in xyz* ; do
  36.    mv $file ${file#xyz}
  37.  done
  38.  
  39.  
  40.    Bjorn
  41.