perl -ne 'next if 0 == $. % 25; print' filename
Here's a somewhat clearer version:
#!/usr/local/bin/perl --
use strict;
use warnings;
my $remove_lines_modulo = 25;
while ( <> ) {
next if 0 == $. % $remove_lines_modulo;
print;
}
Or one that accepts an argument for which lines to remove:
#!/usr/local/bin/perl --
use strict;
use warnings;
my $remove_lines_modulo = shift @ARGV;
die "Cannot handle zero as an argument.\n" if 0 == $remove_lines_modul
+o;
while ( <> ) {
next if 0 == $. % $remove_lines_modulo;
print;
}
Please remember that if this is a homework assignment, it's proper form to say so. Asking for completed work instead of help when it's a school assignment doesn't do any good in the long run and isn't fair to students who actually did the work. |