Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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


Well, 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: