sed: 1: “/etc/hosts”: extra characters at the end of h command
Writing by shivdev on Wednesday, 11 of March , 2015 at 4:11 am
I was trying a simple sed -i on my Mac and was running into
# Does NOT work on Mac
$ sed -i ‘s/^192.168.*vm/192.168.1.12 vm/’ /etc/hosts
sed: 1: “/etc/hosts”: extra characters at the end of h command
A quick google search resulted in stackoverflow getting sed error which has the solution. Apparently, Mac uses BSD sed and Linux uses GNU sed which have different set of arguments. So provide the extra argument in Mac as shown below.
# Adding the extra argument will work on your Mac
$ sed -i ” ‘s/^192.168.*vm/192.168.1.12 vm/’ /etc/hosts
Leave a comment
- Add this post to
- Del.icio.us -
- Digg -
- -
- Tweet -
-
-