I am trying to use sed
to replace '0' with the word 'correct' (I am using echo $?
to validate my script and I want to replace the output of echo
). The problem is that I have more text in the output file and sed
is replacing everything and not just "0".
For example:
some command
echo ``date` `>> "file"
echo $? >> "file"
sed -i 's/0/correct/g' /"file"
Any ideas how could I get this working?
EDIT 1 13.02.2014
Output of echo $?
is "0" (what I know is that 0 means everything is OK).
Next thing is that sed -i 's/0/correct/g' /"file"
(I just used "" because somebody may misinterpret it with specific name).
Here is part of the script:
echo `date` | cat >> /file.txt
echo $? | cat >> /file.txt
sed -i 's/0/correct/g' /file.txt
-i
means:
text Insert text, which has each embedded newline preceded by a back‐slash.