sed command with -i option (in-place editing) works fine on Ubuntu but not Mac [duplicate]
问题 This question already has an answer here: sed -i command for in-place editing to work with both GNU sed and BSD/OSX 7 answers 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 回答1: 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 ''