Please use ***
[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do
not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.
The
-v switch in
grep reverses the match to
exclude any lines containing the expression.
Code:
grep -v "SYSTEM33E14" infile.txt >outfile.txt
As pixellany said, in
vi/
vim, the command would be similar to the
sed syntax, although you need to specify "
g" (global) as well:
Incidentally,
vi[m] can be used directly in scripting. If you run it with the
-e and
-s options, then you can pass it any EX mode commands from stdin.
Code:
printf '%s\n' 'g/SYSTEM33E14/d' 'w outfile.txt' | vim -es infile.txt
('
w' with no arguments will write the changes back to the original file, naturally.)
Although for this kind of thing the lighter
ed is usually recommended instead.
Code:
printf '%s\n' 'g/SYSTEM33E14/d' 'w outfile.txt' | ed -s infile.txt
How to use ed:
http://wiki.bash-hackers.org/howto/edit-ed
http://snap.nlc.dcccd.edu/learn/nlc/ed.html
(also read the info page)
And just to round out the list, here's an
awk solution:
Code:
awk '! /SYSTEM33E14/' infile.txt >outfile.txt