Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get data from specific line.

Status
Not open for further replies.

dbase77

Technical User
Apr 23, 2002
591
IE
hi all,

I run a query against database. The output is line this:

Employee name
-------------
andy
lee
love

Found 3 names.

How do I go about getting just the first entry - "andy". I try to use sed s/data// and exclude the rest and pipe to temp file. But the output is not right as from the above example you have about 7 lines. Since I just need "andy" so line 1-2 is empty line 3 is andy and the rest is empty line. What I need is andy on the first line in temp file. My script went bizarre if cat for empty line and compare to a data. Anybody could help me, please?

Thank you in advance.

regards,
feroz

 
Pipe it through an awk script like this:

[tt]sqlquery | awk '
/^Employee Name/ {
getline
getline
print
}
' > yourtempfile[/tt]

When it matches the "Employee name" line the script is executed; it discards the current and the next line and prints out the contents of the third. Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top