sed command with -i option (in-place editing) works fine on Ubuntu but not Mac

Michelle Williamson picture Michelle Williamson · May 25, 2013 · Viewed 79.8k times · Source

I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX:

sed -i "/ $domain .*#drupalpro/d" /etc/hosts

I'm getting:

sed: 1: "/etc/hosts": extra characters at the end of h command

Answer

microtherion picture microtherion · May 25, 2013

Ubuntu ships with GNU sed, where the suffix for the -i option is optional. OS X ships with BSD sed, where the suffix is mandatory. Try sed -i ''