- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How can I get awk to distinguish between colum...
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
04-11-2005 08:17 AM
04-11-2005 08:17 AM
%kbytes %used %avail
/dev/vg06/testdata4
10485760 8927978 1460428
/dev/vg06/testdata3
7340032 2894101 4168167
/dev/vg06/testdata2
7340032 3545317 3557638
/dev/vg06/mw 1001729 259606 641950
An awk '{print$2}' will only give the %kbyte size for /vg06/mw as the 2nd column output. The %kbytes column for the other longer filesystems shows as {print $1}. What do I have to do to get $2 to print out the %kbytes for each filesystems no matter how long the FS is?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 08:23 AM
04-11-2005 08:23 AM
Re: How can I get awk to distinguish between columns
Does it print what you want??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 08:25 AM
04-11-2005 08:25 AM
Re: How can I get awk to distinguish between columns
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 08:39 AM
04-11-2005 08:39 AM
Re: How can I get awk to distinguish between columns
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=847833
Also post your bdf_output|od -c
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 08:48 AM
04-11-2005 08:48 AM
Re: How can I get awk to distinguish between columns
This question has been answerred a few times before. Unfortunately the (advanced) search in the forum is not helpful. Try to google for:
+hpux +df +awk +site:itrc.hp.com
On the data you showed (which is unlike bdf data I've seen before) this worked:
awk '{if (NF==4) {dev=$1}; if (NF==1) {dev=$1}; if (NF>2) {print dev,$(NF - 2)}}'
Good luck,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 02:53 PM
04-11-2005 02:53 PM
Re: How can I get awk to distinguish between columns
bdf | while read FS TOT USED AVAIL PERCENT MNT
do
if [ "$TOT" = "" ]
then
read TOT USED AVAIL PERCENT MNT
fi
echo "params are $FS $TOT $USED $AVAIL $PERCENT $MNT"
Now you have all 6 parameters regardless of whether the bdf entry is one line or two. Now you can add or test values.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2005 07:25 PM
04-11-2005 07:25 PM
Re: How can I get awk to distinguish between columns
bdf | awk '
{
if (NF<7) { COL1=$1 ; getline; COL2=$1 }
else { COL1=$1 ; COL2=$2 }
print COL1 " " COL2
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2005 12:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2005 12:50 AM
04-12-2005 12:50 AM
Re: How can I get awk to distinguish between columns
BEGIN{daflag=0;}
daflag==1 {$0=dahold" "$0;daflag=0;}
NF>2 {printf("%25s %10d\n", $1,$2);next};
{daflag=1;dahold=$0;}
Then run:
bdf | awk -f useme.awk
The output will give you:
/dev/vg06/testdata4 10485760
/dev/vg06/testdata3 7340032
/dev/vg06/testdata2 7340032
/dev/vg06/mw 1001729
Essentially the script combines lines that are "too small" and then prints $1 and $2 for lines that were long enough or lnies that have been combined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2005 01:02 AM
04-12-2005 01:02 AM