find and replace

Hi,

There are some "n" files in a directory which contains comman string.A command to find and replace the string in all the files without looping.

like if i am in a directory :

# find ./ -name ".txt" | xargs sed -e 's/test/tst'
Upto here is performed correctly and i want to redirect this to the same files.( ie ".txt" replcace )

( As sed replaces but does modify the files so need to redirect to the same files )

Thanks

If you have GNU sed

find ./ -name ".txt"  | xargs sed -i -e 's/test/tst/g' 

Or with perl

find ./ -name ".txt"  | xargs perl -pi -e 's/test/tst/g' 

GNU sed has the -i option (inline edit) which you are looking for

otherwise, use perl instead of sed:

perl -pi -e 's/test/tst/'

I am on HP Unix.

sed has no option "-i" for sed.

perl -pi -e 's/test/test'

Substitution replacement not terminated at -e line 1.
Can't open perl script "s/e/t": No such file or directory

I want to redirect to the same files in the directory

needs the / delimiter on the end of the regexp:

perl -pi -e 's/test/test/'