- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- parsing output with AWK
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
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
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-16-2002 09:45 AM
тАО04-16-2002 09:45 AM
Suppose, I have the following information:
total used free avail
/dev/vg00/lvol3 155648 45189 103603 2402
/dev/vg00/lvol1 99669 36453 53249 16081
/dev/vg00/lvol8 819200 710685 10199 19967
/dev/vg00/lvol7 819200 496611 30248 18973
I would like to summarize total size of all the above columns:
e.g.
total used free avail
/dev/vg00/lvol3 155648 45189 103603 2402
/dev/vg00/lvol1 99669 36453 53249 16081
/dev/vg00/lvol8 819200 710685 10199 19967
/dev/vg00/lvol7 819200 496611 30248 18973
Total: 199999 88392 82883 2811
Does anyone know the easiest to do it in awk?
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 09:54 AM
тАО04-16-2002 09:54 AM
Re: parsing output with AWK
This user has
assign point to 53 out of 123 answer.
LZ i guss you want to total of all used available and used right?
Run following command in one line.
#dbf -l | sort | awk '{t+=$2} {u+=$3} {a+=$4} END {print "\n total = "t " used = u "available = " a}'
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 09:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 09:58 AM
тАО04-16-2002 09:58 AM
Re: parsing output with AWK
Try this:
awk '{t1+=$2} END {print "Total: ", t1}' testfile
Will give you the total for the 2nd Column ...
Do the same thing for the other columns ...
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 10:02 AM
тАО04-16-2002 10:02 AM
Re: parsing output with AWK
#!/bin/sh
bdf -l > file1
SPACE=`cat file1 | grep -v used | grep ts | sort | awk -v s=0 '{s+=$4} {v=s/1000000} END {print v}'`
echo "Free space = ${SPACE}"
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 10:05 AM
тАО04-16-2002 10:05 AM
Re: parsing output with AWK
Here is a combination of mine and JRF's ... easy and efficient ...
awk '{t1=t1+$2;t2=t2+$3;t3=t3+$3;t4=t4+$4;} END {print "Total: ", t1,t2,t3,t4}' testfile
Thanks,
Shabu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 10:14 AM
тАО04-16-2002 10:14 AM
Re: parsing output with AWK
For grins-and-giggles, we could also tally the fields into an array (which might be more suitable for situations involving larger numbers of fields):
# awk 'BEGIN{min=2;max=5};{for (i=min;i<=max;i++) a[i]+=$i};END {for (i=min;i<=max;i++) print a[i]}' /tmp/data
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-16-2002 10:16 AM
тАО04-16-2002 10:16 AM
Re: parsing output with AWK
Filesystem Mount Megs Used Avail %used fs Type
/dev/vg00/lvol3 / 200.0 29.2 160.2 20% vxfs
/dev/vg00/data /data 2000.0 613.4 1300.4 35% vxfs
/dev/vg00/home /home 16.0 1.1 14.0 13% vxfs
/dev/vg00/opt /opt 768.0 549.4 204.9 73% vxfs
/dev/vg00/pro /pro 12000.0 11287.1 690.7 94% vxfs
/dev/vg00/lvol1 /stand 292.1 31.3 231.6 21% hfs
/dev/vg00/tmp /tmp 400.0 233.5 156.7 61% vxfs
/dev/vg00/u /u 1000.0 373.1 587.7 41% vxfs
/dev/vg00/lvol7 /usr 1304.0 616.2 644.9 51% vxfs
/dev/vg00/var /var 504.0 137.5 345.4 31% vxfs
/dev/vg00/wrk /wrk 1000.0 59.8 881.7 12% vxfs
Total 19484.1 13931.6 5218.3 73%