[SunHELP] script request!

Will Mc Donald wmcdonald at ntlworld.com
Fri Sep 20 08:47:41 CDT 2002


Actually, re-reading your question it's unclear whether you meant changing
"nana" to "mona" in the filenames or within the contents of the files
themselves.

The loop I posted changes the filenames...

Will.

----- Original Message -----
From: "Will Mc Donald" <wmcdonald at ntlworld.com>
> The best I can come up with off the top of my head is...
>
> <-------SNIP------->
> #! /bin/bash
> for oldname in `find . -name "*nana*pl" | cut -d '/' -f 2`
> do
>     newname=`echo $oldname | sed 's/nana/mona/'`
>     # echo $newname
>     mv $oldname $newname
> done
> <-------SNIP------->
>
> Not particularly elegant but it works. You could replace the find with an
"ls
> -1 *nana*pl"or something if you only wanted the current directory.
>
> Will.
>
> ----- Original Message -----
> From: "Simon Jespersen" <shj at pine.dk>
>
> > Hi list!
> >
> > I need a script for replacing a string in a number of files in a
directory
> >
> > i want to replace the string "nana" with the string "mona" in all *pl
files
> > i wonder if anybody af a script or a easy way to do that.



More information about the SunHELP mailing list