file operations in shell scripting

hi All,

my query...
1.I Have to search for the files in the root directory.
2.i have to search for a pattern in all the files in the root directory and then replace them with a new pattern.
3.Rename the file

Explanation:
if ABC is the root folder and has 3 subfolders and there are 15 files in total. i am searching for the string December and then i have to change it to January and rename the file which has the desired pattern(e.g December)

i am working on sunos 5.8 and i tried with the sed command but the -i option is not supported.
Please give me some suggestions...

post what you have done....

i am actually waiting for a solution from some gurus ..
i shall update once i am done

u can use the following way..this is part of suggestion and you can carry it from next sequence onward

find / -type f -name <pattern of file> -exec sed 's/search text/replaced text/g' {} \;

this will search the particular pattern of files from root, then search the <search text>and replace the same with <replaced text>

then loop the above one and rename the same .
best of luck..:b:

hi manas ,

wht should i give in place of <file pattern>
I am using sed "s/as/AS/g" $file >> $newfile
but the string 'as' is replaced by 'AS' in all the places. i need to replace it only for the 'as' word but not the string

e.g
file has the contents:
manas
as far as you go
has

output should be:
manas
AS far AS you go
has

but not
manAS
AS far AS you go
hAS

some suggestions pls

If you just want the word, put spaces around it.

"s/ as / AS /g"

if i want to replace "mahi" and "MAHI" with "MAHI_123" then how can i do it without two sed cmds how do i do it?

this is wht i did

sed "s/ mahi / MAHI_123 /g" $file >> $F1

cp $F1 $F1.orig
sed -e "s/ MAHI / MAHI_123 /g" $F1.orig &gt; $F1
rm $F1.orig

can anyone please suggest anything better than this

case insensitive search

Please use code-tags

sed 's/mahi/MAHI_123/gi' filename

when i use the cmd

sed 's/ mahi / MAHI_123 /gi' $file >> $F1 its giving the follwing error

sed: command garbled: s/ mahi / MAHI_123 /gi

am i using it in a proper manner?

What is the sed version being used ?