Deleting a line w/ char match 
Author Message
 Deleting a line w/ char match

i have been trying to duplicate the sed command in deleting
a line in a file after a char match in a line. i am using
the perl command from a system call in a perl program:

ex:

#!/usr/local/bin/perl

system("perl -pi -e 's/string\\n//g' file");

this of course only substitutes a blank for string.
i would like to just delete the line matching string
as in sed:

sed '/string/d' file

any comments would be appreciated

thx
alex



Mon, 06 Mar 1995 01:59:47 GMT  
 Deleting a line w/ char match

Quote:

>i have been trying to duplicate the sed command in deleting a line in a file
>after a char match in a line. i am using the perl command from a system call
>in a perl program:
>ex:
>#!/usr/local/bin/perl
>system("perl -pi -e 's/string\\n//g' file");
>this of course only substitutes a blank for string.  i would like to just
>delete the line matching string as in sed:
>sed '/string/d' file
>any comments would be appreciated

Any?  What if the comments are rude and unrelated?  Oh, nevermind... :-)

Anyhow, try this:

  system("perl -ni -e 'print unless /string/' file");

Michael.



Mon, 06 Mar 1995 08:05:45 GMT  
 Deleting a line w/ char match

Quote:

>i have been trying to duplicate the sed command in deleting
>a line in a file after a char match in a line. i am using
>the perl command from a system call in a perl program:

>ex:

>#!/usr/local/bin/perl

>system("perl -pi -e 's/string\\n//g' file");

Try:

        system("perl -pi -e 'print unless /string$/' file");

Quote:

>this of course only substitutes a blank for string.
>i would like to just delete the line matching string
>as in sed:

>sed '/string/d' file

>any comments would be appreciated

>thx
>alex

Cheers,
Joel

--
     ==================================================================
     ||               T E C H N E   R E S E A R C H                  ||
     ||  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ||
     ||                     Joel Rosi-Schwartz                       ||

     ||   12 Waverley Way            +    (pyrltd!abigale.UUCP!joel) ||
     ||   Finchampstead, Wokingham   +   Phone: +44 (734) 730.260    ||
     ||   Berkshire RG11 4YD (UK)    +   Fax:   +44 (734) 730.272    ||
     ==================================================================



Mon, 06 Mar 1995 18:01:09 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Match any char EXCEPT [char]

2. Deleting lines that match a pattern

3. Delete a line containing a pattern match??

4. tr/y not deleting chars?

5. if last char is comma, delete it

6. Pattern bug matching whitespace in multi-line match?

7. Matching empty line plus string on next line

8. printing lines following the line with a match

9. reading lines from one file and pulling matching lines in another

10. Finding matching line based on surrounding lines

11. printing lines BEFORE a designated matching line ?

12. matching . *and* \n in a char class

 

 
Powered by phpBB® Forum Software