From john-at-wagoneers.com Tue Aug 6 10:30:34 2002
On Tue, 6 Aug 2002, Brian Q wrote:
>-->Is there a way i can take a text file and remove all lines with a current
>-->string in them?
>-->I thought i saw it posted here a while back but couldn't find it in the archives
>-->Thanks
>-->Brian
here's a few ways of doing it... :)
john
========================================
see the slide on global replace:
http://www.wagoneers.com/UNIX/VI-EDITOR/vi-101.html
========================================
http://www.wagoneers.com/UNIX/SED/sed.html
some "sed-like" tricks from within vi:
insert # at beginning of lines
:%s/.*/# &/g - inserts a # at the beginning of every line
:15,$s/.*/# &/g - inserts a # at the beginning of line 15, until the end of the file
:15,250s/.*/# &/g - inserts a # from line 15 through 250.
turn one or more blank spaces into one space
:%s/ */ /g
remove blank lines, or lines with only spaces or tabs
:g/^[ t]*$/d --> WHERE t=tab
redo entire line adding parentheses:
at command line: sed s/.*/( & )/ file > new.file
or
from within vi: :%s/.*/( & )/g
(THERE's MORE, see the link:
http://www.wagoneers.com/UNIX/SED/sed.html )
========================================
http://www.wagoneers.com/UNIX/FILE-TOOLS/find-grep-perl-trick.html
tricks with find, grep and perl
Linux example - find and grep, and perl replacement to
fix a spelling error.
-------------------------------------------------------
find ./ -type f -name '*.htm*' -exec grep Galations {} \;
find ./ -type f -name '*.txt' -exec grep Galations {} \;
find ./ -type f -name '*.htm*' -exec perl -pi -e 's/Galations/Galatians/g' {} \;
find ./ -type f -name '*.txt' -exec perl -pi -e 's/Galations/Galatians/g' {} \;
========================================
http://www.wagoneers.com/UNIX/FIND/find-n-perl-ex.html
find and perl example
find ./ -type f -name '*.htm*' -exec perl -pi -e 's/billygraham.org\/steps.htm/billygraham.org\/spiritualhelp\/steps.asp/g' {} \;
========================================
http://www.wagoneers.com/UNIX/
========================================
----
-------------------------------------------------------------------------
** john-at-wagoneers.com via PINE on Linux ** (plain text please!)
** http://wagoneers.com ** ** http://freegift.net **
Snohomish, Washington USA - where Jeeps don't rust, they mold.
...and remember, leaving life without Jesus just isn't recommended...
-------------------------------------------------------------------------
|
Select pages from WAGONEERS.COM:
Buy this FSJ decal... ...use PayPal to pay for it! |
AMSOIL synthetic lubricants and filters (please use customer #283461)
Shop AMAZON.com from wagoneers.com!
| |||||||
|
these pages protected by US Copyright laws John Meister copyright © 1995-2001 all rights reserved contact john-at-wagoneers.com | "Join the fight against spam (UCE)! Eliminate spam!" |
Washington State has a $500 fine for "spam" (unsolicited commercial email)! |