subtract - delete matching lines from text files
Ever write code that you’re certain has been done a million times but you just don’t know what phrases to type into google to find it? Well, here is a little text utility that fits that criteria.
I call it subtract. It subtracts matching lines from text files (as
seen in title!). It uses grep output format, so I use it like this:
egrep -Hf patterns.txt *.txt | subtract
or like this:
grep -H 'line I want to remove' some_file.txt | subtract
grep output looks like this:
filename:line
filename:line
filename:line
So subtract takes these kinds of lines, opens the file filename
and looks for lines in it matching line, then deletes those lines
from the file. Pretty basic.
Updated: Tue Jul 29 11:38:02 MDT 2008
© 2008 Scott Wiersdorf