snip.pl <filename> <start> [count]
Display <count> lines of <filename> from the line number <start>.
If there is no <count>, display the line number <start>.
<filename> '-' stands for standard input.
Copyright 2000-2007 Etienne LEMEE <coding AT etilem DOT net>
This piece of code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
#!/usr/bin/perl -w use strict; @ARGV > 1 or die << "USAGE"; $0 <filename> <start> [count] display <count> lines of <filename> from the line number <start> if there is no <count>, display the line number <start> <filename> '-' stands for STDIN USAGE my ($file, $start, $count) = @ARGV; $count ||= 1; $. = 0; my $IN; $file eq "-" ? *$IN = *STDIN : open $IN, '<', $file or die $!; while (<$IN>) { print "$.\t$_" if ($. >= $start && $. < $start + $count) }