I\'d like to create a script to comment out lines of my Mac OS X hosts file that contain .com. And also one to reverse it.
.com
So this:
127.0.0.
With awk
awk '$2 ~ /.com/{$0 = "#"$0;}{print}' temp.txt
Output
#127.0.0.1 foo.com #127.0.0.1 bar.com 127.0.0.1 baz 127.0.0.1 qux