One line is all it takes. Here I suppress the lines that match foo by only printing the line if it does not. Redirect the output from STDOUT to a file out.txt and you are done. Use ' instead of " on *nix
C:\>type data.txt foo bar foo bar foo foo C:\>perl -n -e "m/foo/ or print" data.txt > out.txt C:\>type out.txt bar bar C:\>
To match lots of differect stuff you would just match m/this|that|other/ If you wantit long hand it might look like:
#!/usr/bin/perl -w use strict; $ARGV[0] or die "Useage ./$0 file_to_process > output.file\n"; my @finds = qw( this that other ); my $finds_re = join '|', map { quotemeta }@finds; $finds_re = qr/$finds_re/; open F, $ARGV[0] or die $!; while(<F>) { next if m/$finds_re/; print; } close F;
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
In reply to Re: Finding a string within a string
by tachyon
in thread Finding a string within a string
by skyler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |