in reply to Display Line Numbers

Although there are better solutions as has already been suggested above, here is a quick script I just wrote to output 5 lines either side a line number you specify.

Just give it two arguments on the command line when you run it. 1. A line number you want to display, and 2. the file you want to display the line number from.

eg. lnb.pl 14 testfile.txt

This will display lines 9 through to 19 (5 either side of 14) from file testfile.txt

Enjoy!
Dean

#!perl $nmb = shift; $file = shift; open (FILE, "<$file") or die $!; @file = <FILE>; close FILE; print "\n"; foreach (@file) { if (abs($nmb - ++$i) <= 5) { print $i, ":\t$_"; } } print "\n";