- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Column "x" and row "y"
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2009 11:19 PM
тАО09-17-2009 11:19 PM
Hi All,
How can I get the data listed in column "x" and row "y" ??
Example, 2nd column and 4th row contains IP 192.168.15.112
# netstat -rn
Routing tables
Destination Gateway Flags Refs Interface Pmtu
127.0.0.1 127.0.0.1 UH 0 lo0 4136
192.168.15.112 192.168.15.112 UH 0 lan0 4136
16.16.158.112 16.16.158.112 UH 0 lan1 4136
192.168.15.0 192.168.15.112 U 2 lan0 1500
16.16.158.0 16.16.158.112 U 2 lan1 1500
127.0.0.0 127.0.0.1 U 0 lo0 0
default 16.16.158.1 UG 0 lan1 0
Thanks..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2009 11:52 PM
тАО09-17-2009 11:52 PM
Solutionnetstat -rn | sed '4q;d' | awk '{print $2}'
4 = row, starting with 1
2 = column, starting with 1
hth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-17-2009 11:54 PM
тАО09-17-2009 11:54 PM
Re: Column "x" and row "y"
You can do it like this way
netstat -rn | sed -n 4p | awk '{print $2 }'
or
netstat -rn | head -n 4 | awk '{print $2 }
This will extract 2nd column and 4th row.
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 12:33 AM
тАО09-18-2009 12:33 AM
Re: Column "x" and row "y"
>> svo
netstat -rn | sed '4q;d' | awk '{print $2}' <== perfect
>> Suraj
netstat -rn | sed -n 4p | awk '{print $2 }' <== perfect
Can you please explain the meaning of:
sed '4q;d'
and
sed -n 4p
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 12:39 AM
тАО09-18-2009 12:39 AM
Re: Column "x" and row "y"
sed -n 4p means line 4
for more information on sed see the link below it will help you lot
http://www.grymoire.com/Unix/Sed.html
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 12:52 AM
тАО09-18-2009 12:52 AM
Re: Column "x" and row "y"
sed '4q;d'
Quit after the 4th line and delete all before
sed -n 4p
Print line Nr 4
Quit & delete is the better choice in large files, result is the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 01:09 AM
тАО09-18-2009 01:09 AM
Re: Column "x" and row "y"
Is this not worked for you
netstat -rn | head -n 4 | awk '{print $2}'
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 01:14 AM
тАО09-18-2009 01:14 AM
Re: Column "x" and row "y"
# netstat -rn | head -n 4 | awk '{print $2}'
tables
Gateway
127.0.0.1
10.20.180.151
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 01:20 AM
тАО09-18-2009 01:20 AM
Re: Column "x" and row "y"
netstat -rn | awk -v ROW=4 -v COLUMN=2 '
NR == ROW {
print $COLUMN
exit
}'
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-18-2009 03:28 AM
тАО09-18-2009 03:28 AM
Re: Column "x" and row "y"
>> Dennis, I tried this and it worked beautifully..thanks a lot !!
# netstat -rn | awk -v ROW=4 -v COLUMN=2 'NR==ROW {print $COLUMN;exit}'