[TriLUG] Perl question. . .

Brian Henning Brian.Henning at datadirect.com
Tue Feb 17 15:12:34 EST 2009

There's undoubtedly a more elegant way...

BEGIN pickaline.pl:


$targetline = <your desired line number>;
$line = 0;
while(<STDIN>) {
  if($line == $targetline) {
    print $line;

END pickaline.pl


pickaline.pl < sourcefile > destfile

That'll take line number <your desired line number> and put it into a
file called destfile.


-----Original Message-----
From: trilug-bounces at trilug.org [mailto:trilug-bounces at trilug.org] On
Behalf Of Justin Parker
Sent: Tuesday, February 17, 2009 3:00 PM
To: Triangle Linux Users Group General Discussion
Subject: [TriLUG] Perl question. . .

I'd like to read a file and pipe the text on a particular line to a new 
file.  Does anyone have a suggestion on how I could script this?

Thanks for your help,
TriLUG mailing list        :
TriLUG FAQ  : http://www.trilug.org/wiki/Frequently_Asked_Questions

More information about the TriLUG mailing list