Created
March 28, 2012 18:07
-
-
Save codebynumbers/2228857 to your computer and use it in GitHub Desktop.
Yoink lines from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| my $line; | |
| my $i=1; | |
| if($#ARGV == 2){ | |
| open (IN, "<$ARGV[0]") or die "Can't open $ARGV[0]"; | |
| while ($line = <IN>) { | |
| if($ARGV[1] <= $i && $i <= $ARGV[2]){ | |
| print $line; | |
| } | |
| $i++; | |
| } | |
| close(IN); | |
| }else{ | |
| print "Usage: $0 infile start_line_number end_line_number\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment