home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!pipex!bnr.co.uk!bmdhh243!agc
- From: agc@bmdhh286.bnr.ca (Alan Carter)
- Subject: Re: recursive renaming down directory tree. How?
- Message-ID: <1992Nov06.133210.9680@bnr.uk>
- Sender: news@bnr.uk (News Administrator)
- Nntp-Posting-Host: bmdhh286
- Organization: BNR-Europe-Limited, Maidenhead, England
- References: <1992Nov6.044055.18206@cs.ucla.edu>
- Date: Fri, 06 Nov 1992 13:32:10 GMT
- Lines: 41
-
-
- > I have a bunch of files with a .cc suffix and I want to change
- > the suffix to .C. Is there any clever way of doing it rather than
- > manually change every one of them? I kind of know 'find' will help
- > do the trick though.
-
- Hmmm... I wonder whatever you could be doing :-)
-
- There is probably a far more elegant way in perl or awk, but the
- way I did it was to do a little command line script:
-
- $ ls *.cc | while read oldname
- > do
- > basename=`echo $oldname | cut -d'.' -f1`
- > mv $oldname $basename.C
- > done
-
- This will convert a directory full of old source files. To do many
- directories I prefer the following little recursive script to find:
-
- $1 #execute the 1st argument, which could be the name of a script
- for i in *
- do
- if test -d $i
- then
- cd $i
- /users/agc/grimoire/walk $1 # this is me!!!
- cd ..
- fi
- done
-
- Hope this helps, Alan
-
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- To arrive at the simplest truth, as Newton knew and practised, requires years
- of contemplation. Not activity. Not reasoning. Not calculating. Not busy
- behaviour of any kind. Not reading. Not talking. Not making an effort. Simply
- bearing in mind what it is one needs to know.
-
- George Spencer-Brown, Laws of Form
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-