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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a file in Korn shell

Status
Not open for further replies.

hfaix

MIS
Nov 25, 2003
596
US
From a Korn Shell script, I am working on reading a file, based on a grep or awk command for a specific string, and can't figure out a way to return the line number where the string is found in the file. I think I could do this with a counter and variable but this would create a lot of extra coding, so I wondered if there is a system-KORN way to do it. I'm also in an AIX enviroment if that helps. $LINENO only seems to work in the executing script, not in the read file.

Any help would be great!

Thanks
 
GNU grep has an option (
Code:
-n
) to print the line number where the match was found.

//Daniel
 
Ah.... Thanks, I didn't even think of that. I should have looked at the man grep. Thanks for the help!



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top