Skip to content

Instantly share code, notes, and snippets.

@codebynumbers
Created March 28, 2012 18:07
Show Gist options
  • Select an option

  • Save codebynumbers/2228857 to your computer and use it in GitHub Desktop.

Select an option

Save codebynumbers/2228857 to your computer and use it in GitHub Desktop.
Yoink lines from a file
#!/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