summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2018-12-23 19:46:35 +0100
committerFlorian Pritz <bluewind@xinu.at>2018-12-23 19:46:35 +0100
commit4f29f21d7cb38eb36a1d652c6d9d10bd6687387d (patch)
treedea5b305833bba03c0e3d711a6c0a4383fa9ed40
parentdd9e411b3722a6b7361ab4c179028c83e30909c2 (diff)
downloadbin-4f29f21d7cb38eb36a1d652c6d9d10bd6687387d.tar.gz
bin-4f29f21d7cb38eb36a1d652c6d9d10bd6687387d.tar.xz
long-lines.pl: Add option to skip lines by regex
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rwxr-xr-xlong-lines.pl4
1 files changed, 3 insertions, 1 deletions
diff --git a/long-lines.pl b/long-lines.pl
index f0a117f..35ef85a 100755
--- a/long-lines.pl
+++ b/long-lines.pl
@@ -7,13 +7,14 @@ use Text::Tabs;
use Carp;
my %opt;
-getopts("hm:t:", \%opt);
+getopts("hm:t:s:", \%opt);
if (@ARGV == 0 || $opt{h}) {
print "usage: ", basename($0), " [options] file(s)...\n\n";
print "Options:\n";
print " -m NUMBER maximum chars tolerated per line (default: 80)\n";
print " -t NUMBER count \\t as NUMBER chars (default: 4)\n";
+ print " -s REGEX skip lines that match this regular expression\n";
print " -h this help\n";
exit 0;
}
@@ -31,6 +32,7 @@ for my $file (@ARGV) {
$line = 0;
while (<$fh>) {
$line++;
+ next if defined $opt{s} and m/$opt{s}/;
$_ = expand $_;
if (length > $max) {
print "\"$file\" - line $line: ", length, " chars\n";