...
The -i signifies inline editing and also will have sed automatically creates a backup file. If you want to specify the suffix of the backup file you may add .suffix. For example to create the backup file with the extension .baksedautobck,
Code Block | ||
---|---|---|
| ||
sed -i.baksedautobck 's/cow/reindeer/' hey.txt |
...
Code Block | ||
---|---|---|
| ||
sed -i.baksedautobck 's/coy/reindeer/' hey.txt cmp -s hey.txt hey.txt.baksedautobck && echo "sed did not work, your files are identical." sed did not work, your files are identical. |
This time I do it right,
...
language | bash |
---|
...
With the mistake you get the extra third line, "sed did not work, your files are identical.".
And if we want to be more fancy to make the cmp line more generic,
Code Block | ||
---|---|---|
| ||
sed -i.baksedautobck 's/coy/reindeer/' hey.txt cmp -s $_ $_.baksedautobck && echo "sed did not work, your files are identical." |
...