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

NR ?

Status
Not open for further replies.

linmac

Technical User
Aug 21, 2002
7
MY
I got script

.....
lineno=0
syscommnand | awk 'NR>$lineno && NR<$lineno-2 {print $2, $6)'
let lineno=$lineno+10
...

but the script doesn't work b'cause the $lineno in &quot;NR&quot;, how can I pass the variable to NR? or can someone give me better code b'cause I am new to awk. thanx in very advance.
 


Hi,
The problem here isn't NR but the fact tahee $lineno is a SHELL variable which is not being processed before getting set to awk because you have single quotes around it.

you might want to see

How can I access shell variables in awk
faq271-1281

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top