home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13036 < prev    next >
Encoding:
Text File  |  1992-11-07  |  1.7 KB  |  54 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!pipex!bnr.co.uk!bmdhh243!agc
  3. From: agc@bmdhh286.bnr.ca (Alan Carter)
  4. Subject: Re: recursive renaming down directory tree.  How?
  5. Message-ID: <1992Nov06.133210.9680@bnr.uk>
  6. Sender: news@bnr.uk (News Administrator)
  7. Nntp-Posting-Host: bmdhh286
  8. Organization: BNR-Europe-Limited, Maidenhead, England
  9. References:  <1992Nov6.044055.18206@cs.ucla.edu>
  10. Date: Fri, 06 Nov 1992 13:32:10 GMT
  11. Lines: 41
  12.  
  13.  
  14. >    I have a bunch of files with a .cc suffix and I want to change
  15. > the suffix to .C.   Is there any clever way of doing it rather than
  16. > manually change every one of them?  I kind of know 'find' will help
  17. > do the trick though.
  18.  
  19. Hmmm... I wonder whatever you could be doing :-) 
  20.  
  21. There is probably a far more elegant way in perl or awk, but the
  22. way I did it was to do a little command line script:
  23.  
  24. $ ls *.cc | while read oldname
  25. > do
  26. > basename=`echo $oldname | cut -d'.' -f1`
  27. > mv $oldname $basename.C
  28. > done
  29.  
  30. This will convert a directory full of old source files. To do many 
  31. directories I prefer the following little recursive script to find:
  32.  
  33. $1  #execute the 1st argument, which could be the name of a script
  34. for i in *
  35. do
  36. if test -d $i
  37. then
  38. cd $i
  39. /users/agc/grimoire/walk $1   # this is me!!!
  40. cd ..
  41. fi
  42. done
  43.  
  44.    Hope this helps, Alan
  45.  
  46. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  47. To arrive at the simplest truth, as Newton knew and practised, requires years
  48. of contemplation. Not activity. Not reasoning. Not calculating. Not busy 
  49. behaviour of any kind. Not reading. Not talking. Not making an effort. Simply 
  50. bearing in mind what it is one needs to know.
  51.  
  52.    George Spencer-Brown, Laws of Form
  53. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  54.