I'm writing little Sed wrapper. It's task is to replace text. I have to override original file.
so my first try was:
sed s/$1/$2/g <$3 >$3
and i got empty file. Hire is my first question: why for commend like this:
./my_script foo bar file
and file like this
file is empty instead of one "bar" word?
Anyway I fixed this with:
sed s/$1/$2/g <$3|cat >$3
And It works! But I'm not sure why? I think I should get only one bar word because when first line is outputted the input file is maked.
The second approach works but maybe I should better use tmp file?
Sorry for my poor English. And TIA for answers.