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 -->
  #2 (permalink)  
Old 01-31-2008
Karthikeyan_113 Karthikeyan_113 is offline
Registered User
 

Join Date: Jan 2007
Location: Boston, USA
Posts: 16
Thumbs up Try this....

Try the below code.
Code:
echo "Enter the PID :"
read pid
linenum=`cat tes.txt | tr -s " " "|" | cut -d"|" -f2 |grep -n $pid`
cat tes.txt | head -$linenum | tail -1
Its giving the expected results.


==========
Thanks,
Karthikeyan.
==========
Reply With Quote