- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Displaying output from df -k in GB instead of ...
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-13-2007 06:39 AM
тАО09-13-2007 06:39 AM
Code below:
[CODE]
echo "Oracle Filesystems"
echo "------------------"
echo
for j in `df -l -k |grep total|grep ora|grep -v storage|grep -v vg00|awk '{print $1}'`
do
echo $j is `df -l -k $j |grep total|grep ora|grep -v storage|grep -v vg00|awk -F":" '{print $2}'|awk '{print $1}'` KB
done
echo
[/CODE]
Here is the output:
Oracle Filesystems
------------------
/ora_1 is 369437312 KB
/ora_2 is 369438640 KB
/ora_3 is 366768144 KB
I want to dsiplay the output of df -k in GB instead of KB. How would I do that?
Solved! Go to Solution.
- Tags:
- df
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 06:45 AM
тАО09-13-2007 06:45 AM
SolutionBill Hassell has a 'bdf' script which allows output in MB or GB and more importantly handles the case of multi-line output for any filesystem.
Why re-invent the wheel, when Bill offers his documented script here:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1124262
You can also select only the filesystems you want reported when you run it, just like the standard 'bdf'.
Regards!
...JRF...
- Tags:
- bdfmegs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 06:46 AM
тАО09-13-2007 06:46 AM
Re: Displaying output from df -k in GB instead of KB
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1048509
I would think you could use that.
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 06:46 AM
тАО09-13-2007 06:46 AM
Re: Displaying output from df -k in GB instead of KB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 06:47 AM
тАО09-13-2007 06:47 AM
Re: Displaying output from df -k in GB instead of KB
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1124262
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 08:24 AM
тАО09-13-2007 08:24 AM
Re: Displaying output from df -k in GB instead of KB
Good.
But indulge me, and take an other look at the original script.
It runs 6 processes on the first real line,
and then N times 6 more for each oracle mount point, for a grand total of 24 in the example, all this for data which is right there for the grab / filter all along.
Stuff like that makes performance folks cry, cringe, or snicker depending on their mood.
Check out this 'one liner'.
It does the same job with 2 commands:
df -k -l | awk 'BEGIN{print "Oracle Filesystems\n------------------\n"} END{print ""} /ora/&&!/vg00/{print $1,"is",$5,"Kb"}'
Now change the main print to printf and pass $5/1024 instead of $5 as found and voila!
In script form...
------------------
#!/bin/sh
df -k -l | awk '
BEGIN {print "Oracle Filesystems\n------------------\n"}
END {print ""}
/ora/ && !/vg00/ && !/storage/ {
printf ("%-20s is %5.1f Gb\n",$1,$5/1024)
} '
------------------
Of course it matters little for a task like posted, but it's the principle of things.
Also, I'd like to think that if the task had been solved along the lines above, then any Unix hacker in your environment, and many a Windoze person, could have handled the improvement request.
Hope this helps someone some day,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 02:06 PM
тАО09-13-2007 02:06 PM
Re: Displaying output from df -k in GB instead of KB
> /ora_1 is 369437312 KB
> /ora_2 is 369438640 KB
> /ora_3 is 366768144 KB
You can get not only the selected filesystems but also a sum total for them from bdfmegs:
echo "Oracle Filesystems"
echo "------------------"
bdfmegs -g -s /ora_*
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 03:12 PM
тАО09-13-2007 03:12 PM
Re: Displaying output from df -k in GB instead of KB
Hein van den Heuvel,
I like your method. Thank you too!
One thing I noticed is that I had to make the following line:
printf ("%-20s is %5.1f Gb\n",$1,$5/1024)
Look like this:
printf ("%-20s is %5.1f Gb\n",$1,$5/1024/1024)
To get true GB readings.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 04:04 PM
тАО09-13-2007 04:04 PM
Re: Displaying output from df -k in GB instead of KB
df -l -k |grep total|grep -v ora|grep -v ebr|grep -v vg00|awk -F":" '{print $2}'|awk '{print $1}' > sizes.flatfiles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-13-2007 04:28 PM
тАО09-13-2007 04:28 PM
Re: Displaying output from df -k in GB instead of KB
df -k -l | awk '
/total/ && !/ora/ && !/vg00/ && !/ebr/ {
printf ("%5f\n",$5) >> "sizes.flatfiles"
} '
Too bad i can't give myself points!