wagoneers.com



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...  
-------------------------------------------------------------------------




wagoneers.com




Select pages from WAGONEERS.COM: 

the Full Size Jeep decal! © 1998-2000 John Meister
Buy this FSJ decal...   ...use PayPal to pay for it!
Make payments with PayPal, or sign up here!


a viable option to bloated and unstable code


AMSOIL synthetic lubricants and filters
(please use customer #283461)

Independent Lifetime Dealer John Meister - customer #283461 - since 1983


Shop AMAZON.com from wagoneers.com! 
Search:
Keywords:
SHOP from wagoneers.com: in Association with Amazon.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)!


this is an approved Family-Friendly Site       read the Bible