The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 01-31-2008
KevinADC KevinADC is offline
Registered User
 

Join Date: Jan 2008
Posts: 338
Edit: Do not try this code, it's got a couple of errors. See below for corrected version.


Quote:
Originally Posted by ghostdog74 View Post
you could just post your Perl solution. If OP wants a Perl solution, he will use it.
You're right mate. I am not sure what he wants printed out, the whole line or just part of the data, but this prints the whole line associated with the PID number:

Code:
use strict;
use warnings;
print "Enter the PID :"
my $pid = <STDIN>;
chomp $pid;
open (IN , "tes.txt");
while (<IN>) {
   print if (/^\s*$pid\s/); 
   last;
}
close IN;
exit;

Last edited by KevinADC; 01-31-2008 at 03:43 AM..
Reply With Quote