Replacing a string

Hi All,

I have a many folders in a directory under which there are many subdirectories containing text files containing the word "shyam" in them.I want all the files in all the directories containing "shyam to "ram" ??

sed "s/shyam/ram/g" does it ??But anyone can help me with the script ??

Thanks

I did not test this, but something like...

find <top-level-directory> -type f | while read INFILE
do
        if grep -q shyam ${INFILE} 
        then
                sed -e "s/shyam/ram/g" ${INFILE} > tmpfile
                mv tmpfile ${INFILE}
        fi
done
1 Like

It worked..

Thanks a lot..

one doubt though..What does the sed "-e" do ?

If you have a doubt about what a command option does, you should first consult the command's manual page.

1 Like