- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep only one column
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
Forums
Discussions
Discussions
Discussions
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
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
03-18-2002 09:04 AM
03-18-2002 09:04 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:15 AM
03-18-2002 09:15 AM
Re: grep only one column
bdf|cut -fx
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:17 AM
03-18-2002 09:17 AM
Re: grep only one column
something simple ..
# bdf|awk '{print $1}'
==> will print 1st column
# bdf|awk '{print $2}'
==> will print 2nd column .. and so on.
A good book on awk and sed is the O'Reilly book.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:22 AM
03-18-2002 09:22 AM
Re: grep only one column
avail
89711
44471
230522
1847582
and only this part. any idea?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:24 AM
03-18-2002 09:24 AM
Re: grep only one column
# bdf|awk '{print $4}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:24 AM
03-18-2002 09:24 AM
Re: grep only one column
now it is working. thak you for help!!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:25 AM
03-18-2002 09:25 AM
Re: grep only one column
You can use:
bdf | awk '/some_text/ {print $1}'
The result would be as if you only printed the first column from:
bdf | grep some_text
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:30 AM
03-18-2002 09:30 AM
Re: grep only one column
bdf | awk '{print $4}'
No grep needed since you are looking just for the 4th field where a field is separated by whitespace. However, this will FAIL if the bdf is split scross 2 lines (as in a long NFS mountpoint). In that case, you'll need something a bit more sophisticated:
bdf | while read FS TOT USED AVAIL PERCENT MNT
do
if [ "$TOT" = "" ]
then
read TOT USED AVAIL PERCENT MNT
fi
echo $AVAIL
done
The advantage of the above code is that it will handle a 2-line bdf and also extracts all the rest of the columns, not just $AVAIL.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2002 09:51 AM
03-18-2002 09:51 AM
Re: grep only one column
I bet now you wish to omit the column heading and you can do that by using grep -v
bdf | awk '{ print $4 }' | grep -v avail
Ron's answer was also correct and simpler.
bdf | cut -f4 | grep -v avail
cheers
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2002 05:51 AM
03-19-2002 05:51 AM
Re: grep only one column
I wasn't in on this thread but... I wanted to thank you for the valuable learning experience you provided in your "Sophisticated Code" example.
GREAT STUFF! :)
~jdk