Deleting a line from a file matching criteria
I was messing around trying to figure out an easier way to remove entries from my /etc/portage/package.keywords file without having to drop into VI all the time and came up with this. You can put this into a bash script to make things alot easier on yourself if you are constantly altering your mask/use/keywords files in Gentoo.
The above example will remove any line that matches the regular expression x11-wm/compiz and edit the file in place "-i".
sed -i '/x11-wm\/compiz/d' /etc/portage/package.keywords
The above example will remove any line that matches the regular expression x11-wm/compiz and edit the file in place "-i".