Tuesday, 16 April 2013

greping particular range of lines in a file

open(FILE,"/etc/passwd");
$f=$ARGV[0];
$l=$ARGV[1];
while($line=<FILE>)
{
$d++;
if(($d>$f)&&($d<$l))
{
print $line."\n";
}
}
close(FILE);

usage: perl scriptname "line start" "endline"

No comments:

Post a Comment