![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying Output in Columns | jjamd64 | Shell Programming and Scripting | 1 | 04-25-2008 07:46 AM |
| displaying $ in data | ammu | UNIX for Dummies Questions & Answers | 2 | 02-19-2008 03:00 PM |
| displaying output in a table. | sanchopansa | Shell Programming and Scripting | 6 | 10-06-2006 01:22 PM |
| displaying with ls | vivekshankar | UNIX for Dummies Questions & Answers | 2 | 05-23-2005 04:46 PM |
| Displaying Script command with output | JeDi | Shell Programming and Scripting | 5 | 04-30-2004 12:09 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Displaying output from df -k in GB instead of KB
Hello all, 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
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? |
|
||||
|
Gb
If you can extract the Kb figure into a variable you can turn it into Mb with bc
if $size contains your Kb figure $(echo "scale=2;${size} / 1000000" | bc) will return a Gb figure - the 'scale=2' set the No of decimal places |
|
||||
|
Found another way too using AWK:
Code:
df -k -l | awk '
BEGIN {print "Oracle Filesystems\n------------------\n"}
END {print ""}
/ora/ && !/vg00/ && !/storage/ {
printf ("%-20s is %5.1f Gb\n",$1,$(NF-3)/1024/1024)
} '
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|