[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:
#!/usr/bin/perl
$targetline = <your desired line number>;
$line = 0;
while(<STDIN>) {
$line++;
if($line == $targetline) {
print $line;
die();
}
}
END pickaline.pl
usage:
pickaline.pl < sourcefile > destfile
That'll take line number <your desired line number> and put it into a
file called destfile.
~B
-----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,
Justin
--
TriLUG mailing list :
http://www.trilug.org/mailman/listinfo/trilug
TriLUG FAQ : http://www.trilug.org/wiki/Frequently_Asked_Questions
More information about the TriLUG
mailing list