- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk question
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
06-14-2006 04:46 PM
06-14-2006 04:46 PM
How to get free space left on file system /var/opt/ignite/recovery/archives
from the following output?
root@lev />bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 1048576 318056 724872 30% /
/dev/vg00/lvol1 1081344 178744 895592 17% /stand
/dev/vg00/lvol10 20480000 9382744 11010664 46% /var
/dev/vg01/ignite 116686848 101012876 14694408 87% /var/opt/ignite/recovery/archives
/dev/vg00/lvol9 3768320 2676568 1083264 71% /usr
/dev/vg00/lvol6 1048576 140544 900976 13% /tmp
/dev/vg00/lvol8 20480000 2682088 17658928 13% /opt
/dev/vg00/lvol7 1048576 23512 1021288 2% /home
/dev/vg00/lvol5 10256384 3250963 6567630 33% /depot
/dev/vg00/lvol4 2097152 1888853 195328 91% /.audit
anny:/ignite 143327232 51600 134320912 0% /ignite_Old
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2006 04:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2006 04:54 PM
06-14-2006 04:54 PM
Re: awk question
bdf |grep -i /var/opt/ignite/recovery/archives |awk '{print $4}'
output will be in KB
-Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2006 04:57 PM
06-14-2006 04:57 PM
Re: awk question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2006 08:02 PM
06-14-2006 08:02 PM
Re: awk question
this u can use and get the bdf result in mb.
============================================================
#!/usr/bin/ksh
echo "Filesystem Mbytes used avail %used Mounted on"
bdf | grep -v Filesystem | awk '{ printf("%s %10d %10d %10d %4s %s\n",$1,$2/1024,$3/1024,$4/1024,$5,$6)}'
============================================================
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 12:46 AM
06-15-2006 12:46 AM
Re: awk question
# df -b
rgs,
ran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 12:48 AM
06-15-2006 12:48 AM
Re: awk question
df -b|grep -i ignite
/var/opt/ignite/recovery/archives (/dev/vgvarignite/lvrecovery) : 7676261 Kbytes free
rgs,
ran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 08:46 AM
06-15-2006 08:46 AM
Re: awk question
without awk:
bdf | head -5| tail -1 | tr -s ' ' | cut -f4 -d' '
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 01:34 PM
06-15-2006 01:34 PM
Re: awk question
bdf /var/opt/ignite/recovery/archives
No grep, no awk, nothing but bdf. You could pipe the second line from bdf into read and extract just the free space:
bdf /var/opt/ignite/recovery/archives | while read HEADER REPLY
do
if [ "$HEADER" = "Filesystem" ]
then
read DEV CAP USED FREE PCT FS
MEGSFREE=$(echo $FREE | awk '{print int($1/1024+.5)}')
echo "$FS has $FREE Kbytes ($MEGSFREE megs) free space"
fi
done
The above shows both Kb and megs.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 05:56 PM
06-15-2006 05:56 PM
Re: awk question
I think Igors problem was the 2line-output of the bdf command for long device names; Bills response will handle that.
To get a bdf-like 1line-output for further processing in all cases, I suggest (untested):
bdf | awk 'NR>1 {if(ok) print line; ok=0;line=$0}
NF==1 {line=line" "$0;ok=1}
NF>5 {ok=1}
END {print line}'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 07:07 PM
06-15-2006 07:07 PM
Re: awk question
http://www.gentoo.com/di/
Heh, I didn't know the reference to binary packages from there would be to *my* site. Bet I will have to make 4.5 available soon now, won't I ...
a5:/u/usr/merijn 109 > di -?
di: illegal option -- ?
di ver 4.1 Default Format: smbuvpT
Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]
[-I include-fstyp-list] [file [...]]
-a : print all mounted devices
-d x : size to print blocks in (512 - POSIX, k - kbytes,
m - megabytes, g - gigabytes, t - terabytes, h - human readable).
-f x : use format string
-I x : include only file system types in
-x x : exclude file system types in
-l : display local filesystems only
-n : don't print header
-t : print totals
Format string values:
m - mount point M - mount point, full length
b - total kbytes B - kbytes available for use
u - used kbytes c - calculated kbytes in use
f - kbytes free v - kbytes available
p - percentage not avail. for use 1 - percentage used
2 - percentage of user-available space in use.
i - total file slots (i-nodes) U - used file slots
F - free file slots P - percentage file slots used
s - filesystem name S - filesystem name, full length
t - disk partition type T - partition type, full length
See manual page for more options.
Exit 1
a5:/u/usr/merijn 110 > di -ff /tmp
Free
499.2
a5:/u/usr/merijn 111 > di -n -ff /tmp
499.2
a5:/u/usr/merijn 112 > di -n -ff -dm /tmp
499.2
a5:/u/usr/merijn 113 > di -n -ff -dk /tmp
511221
a5:/u/usr/merijn 114 >
http://mirrors.develooper.com/hpux/di-4.1-10.20.sd.bz
http://mirrors.develooper.com/hpux/di-4.1-11.00.sd.bz
http://mirrors.develooper.com/hpux/di-4.1-11.11.sd.bz
http://mirrors.develooper.com/hpux/di-4.1-11.23.sd.bz
http://mirrors.develooper.com/hpux/di-4.4-11.23.sd.bz
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 08:04 PM
06-15-2006 08:04 PM
Re: awk question
a5:/u/usr/merijn 101 > di -?
di: illegal option -- ?
di ver 4.5 Default Format: smbuvpT
Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]
[-I include-fstyp-list] [file [...]]
-a : print all mounted devices
-d x : size to print blocks in (512 - POSIX, k - kbytes,
m - megabytes, g - gigabytes, t - terabytes, h - human readable).
-f x : use format string
-I x : include only file system types in
-x x : exclude file system types in
-l : display local filesystems only
-n : don't print header
-t : print totals
Format string values:
m - mount point M - mount point, full length
b - total kbytes B - kbytes available for use
u - used kbytes c - calculated kbytes in use
f - kbytes free v - kbytes available
p - percentage not avail. for use 1 - percentage used
2 - percentage of user-available space in use.
i - total file slots (i-nodes) U - used file slots
F - free file slots P - percentage file slots used
s - filesystem name S - filesystem name, full length
t - disk partition type T - partition type, full length
See manual page for more options.
http://www.cmve.net/~mbrand/di-4.5-10.20.sd.bz
http://www.cmve.net/~mbrand/di-4.5-11.00.sd.bz
http://www.cmve.net/~mbrand/di-4.5-11.11.sd.bz
http://www.cmve.net/~mbrand/di-4.5-11.23.sd.bz
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 08:07 PM
06-15-2006 08:07 PM
Re: awk question
bdf var/opt/ignite/recovery/archives|\
awk 'BEGIN {printf "%-16s %14s %14s %14s %8s %s\n","Filesystem","kbytes","used","avail","%used","Mounted on"}
!/Filesystem/ {KBYTES=KBYTES+$2; USED=USED+$3; AVAIL=AVAIL+$4; NBR=++NBR}
END {printf "%-16s %14s %14s %14s %7s \n","================","===========","==========","==========","===="
printf "%-16s %14d %s %11d %s %11d %s %4d% \n","total",KBYTES,"Kb",USED,"Kb",AVAIL,"Kb",USED*100/KBYTES
printf "%-16s %14d %s %11d %s %11d %s \n"," ",KBYTES/1024,"Mb",USED/1024,"Mb",AVAIL/1024,"Mb"
printf "%-16s %14d %s %11d %s %11d %s \n"," ",KBYTES/1048576,"Gb",USED/1048576,"Gb",AVAIL/1048576,"Gb"}
HTH,
Art
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2006 11:58 PM
06-15-2006 11:58 PM
Re: awk question
bdf /house | while read HEADER REPLY
do
if [ "$HEADER" = "Filesystem" ]
then
read DEV CAP USED FREE PCT FS
[[ "$CAP" = "" ]] && read CAP USED FREE PCT FS
MEGSFREE=$(echo $FREE | awk '{print int($1/1024+.5)}')
echo "$FS has $FREE Kbytes ($MEGSFREE megs) free space"
fi
done
Bill Hassell, sysadmin