sed trick

I discovered a new sed trick today:

sed -i~

“I” stands for “in place”. It edits the files in place! And makes a backup if you want!

One thought on “sed trick

  1. It’s a great trick indeed! For those who don’t know; Beware that not all implementations of sed supports the -i option. When writing scripts that need to run on multiple nix-variants it’s good to keep in mind if anything doesn’t work as planned. It’s possibly options like this you need to check on that platform. I’ve come across a number of these at https://cat-v.org, the suckless folks also keeps reminders around on their sites (https://suckless.org, https://suckless.org/people). I just found that busybox sed also has the “-i” option, so for writing scripts for most embedded systems the -i option for sed will work.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.