find/replace?

Dear All
To find a file, according to you, I tried as:
#find / -name file-name -print
To find a string inside the files , I tried as :
#find / -name "*" |xargs grep "string"
Can you please let me know how can I try for find/replace (i.e.
finding the intended string inside the text files and replace it with
another string)?
Thank you

there are many ways to do this. for example: sed, perl -p -i -e
search for examples. there are many

Sorry, I didn't get the point clearly. In the find text below:
#find / -name "*" |xargs grep "string1"
Can you please show me how can I modify the above command to find 'string1' and then replace it with 'string2'?

replace first occurance

perl -p -i -e 's/string1/string2/' file1

also; dont use -name '*'; find / -print will accomplish the same thing. what your doing is potentially dangerous because it will examine every file on the system.

Thank you very much for your reply. As I have understood, your proposed command will replace 'string1' with 'string2' inside the 'file1' .Am I correct?
If yes, can you please let me know how to generalize it to find 'string1' and replace it with 'string2' inside all of the text files under an specific folder?

You can use a small script to do this... The below should work, u can enhance the below to ur exact requirements.....

 
#!/bin/ksh
for file in `find /path/where/you/want/to/search -type f -name "*.txt"`
do
sed -i 's/str1/str2/g' $file
done

I tried for your code but it is returning as :
'sed: illegal option --i'
Can you please correct me?