Hi.
I have the same problem, but I solve it, with out the need of any scrypt and without the side effect of changing the permissions or the owner of the file, because the mv command.
You say that
Quote:
sed s/x/y/g file1 file1
changes all the 'x's to 'y' in file1.
|
but is not truth, I try and do not work, even for a single file :-( ...
that because the sed is a little limited, they can't change a file while reading him.
But i find a simple way of do what you want, a simple command, nothing more nothing less.
The command is the follow.
Code:
find . -name "*.html" -exec sh -c 'sed "s/x/y/g" $0 > $0.tmp; cat $0.tmp > $0; rm $0.tmp' {} \;
This command it's simple to change to your needs, and define what files do you wnat to change or not.
And if you dont want to go through the subfolders you can just add
to the find command.
You can type
to know more about it.
And remember, if you want to find the solution, it's because find is the solution :-)
Just kidding...