2 ms·
Yes, in-place editing with tools like sed is dangerous. But, in your own example you have a useless use of cat: cat $FILENAME | sed $SEDOPTIONS "s/$SEARCHTE
by pmoriarty 4y ago
Yes, in-place editing with tools like sed is dangerous.
But, in your own example you have a useless use of cat:
cat $FILENAME | sed $SEDOPTIONS "s/$SEARCHTERM/$REPLACEMENT/g"
could be replaced with:
sed $SEDOPTIONS "s/$SEARCHTERM/$REPLACEMENT/g" < $FILENAME
- lelanthran 4y agoWell, that's the whole point of the useless use of cat - in the non-cat example you gave, making a typo at the end of the command destroys my data. With the useless use of cat, that is no longer possible even if there is a typo in the SEDOPTIONS.