Skip to main content
10 events
when toggle format what by license comment
Feb 11, 2014 at 18:06 comment added Nikole Cooool, thanks again for all your help. This has made changing my hosts file trivial :)
Feb 11, 2014 at 17:48 comment added terdon @SonofLysander yes, you're quite right, that was a mistake. Fixed now.
Feb 11, 2014 at 17:48 history edited terdon CC BY-SA 3.0
added 1 characters in body
Feb 11, 2014 at 17:47 comment added Nikole Fantastic, this all makes a lot of sense. One question I have, should the first command really be sed -i '/^10\.4/{s/^#//}' /etc/hosts? I think it might need to be sed -i '/^#10\.4/{s/^#//}' /etc/hosts in order to find lines that start with a #.
Feb 11, 2014 at 17:46 vote accept Nikole
Feb 10, 2014 at 20:57 history edited terdon CC BY-SA 3.0
added 3 characters in body
Feb 10, 2014 at 20:52 history edited terdon CC BY-SA 3.0
added 3 characters in body
Feb 10, 2014 at 20:52 comment added terdon @glennjackman good point. That's how I had it originally but then though of cases where there were leading spaces. Still, comments after the IP are very likely as you point out so answer edited, thanks.
Feb 10, 2014 at 20:49 comment added glenn jackman For removing the comment, I'd be conservative and add an ^ anchor in both regexes, in case the file has 210.4.5.6 foobar # this is a host
Feb 10, 2014 at 20:46 history answered terdon CC BY-SA 3.0