ashsysad
asked on
Awk syntax needed
I have a command output like this:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.20.66.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.95.0 0.0.0.0 255.255.255.0 U 0 0 0 usb0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 usb0
0.0.0.0 10.20.66.1 0.0.0.0 UG 0 0 0 eth0
I need an awk statement that will output the 3rd line of the output and assigns to a varaible.
10.20.66.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
In addition, I want to assign "eth0" (last item) to another variable. Please assist.
Thanks !
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
10.20.66.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.95.0 0.0.0.0 255.255.255.0 U 0 0 0 usb0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 usb0
0.0.0.0 10.20.66.1 0.0.0.0 UG 0 0 0 eth0
I need an awk statement that will output the 3rd line of the output and assigns to a varaible.
10.20.66.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
In addition, I want to assign "eth0" (last item) to another variable. Please assist.
Thanks !
NR==3{linethree=$0;linethr eelast=$NF }
ASKER
I'm getting syntax error:
# netstat -rn | awk {NR==3'{linethree=$0;linet hreelast=$ NF}'}
awk: {NR==3{linethree=$0;lineth reelast=$N F}}
awk: ^ syntax error
I'm not that comfortable with AWK. Please give me the full syntax.
# netstat -rn | awk {NR==3'{linethree=$0;linet
awk: {NR==3{linethree=$0;lineth
awk: ^ syntax error
I'm not that comfortable with AWK. Please give me the full syntax.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thankyou !