Yoink - Grab lines from a file





8
Date Submitted Thu. Jan. 25th, 2007 11:16 AM
Revision 1 of 1
Helper RobHarrigan
Tags File | grab | lines | yank | yoink
Comments 0 comments
Use this utility to grab lines from a file. Arguments are the input file, starting ling number and ending line number.

#!/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";
}
 

rob Harrigan

Comments

There are currently no comments for this snippet.

Voting