Need Generic command for disk space usage

Given this directory /web

I need to get the current usage (in %) on Linux and Unix both using the same command on bash shell ?

The command i tried was working on Unix (solaris) but does not filter the desired same value when run of Linux.

My command df -h /web | awk '{print $5}' | sed -n '2p'

Can you help me with a generic command for both unix and linux?

What output do you get from:

df -Ph /web

on your Linux system? What Linux distribution are you using?

What output do you get from the commands:

/usr/xpg4/bin/df -Ph /web

and:

df -h /web

on your Solaris system? What Solaris release are you using?

1 Like

Please be aware that df prints results for file systems, NOT directories.
Is df aliased to sth. different on your linux system? On my system, your pipe in post#1 works as desired...

1 Like

You are such an Amazing expert ...

df -Ph resolved the issue.

I will provide more data you requested in the near future.

df -Pk is most portable (e.g. works on Solaris 8) with a Posix PATH.
Print the 5th field

PATH=`getconf PATH`
df -kP /web | awk 'NR>1 {print $5}'

Print the 5th field without the % sign

df -kP /web | awk 'NR>1 {print $5+0}'
1 Like

I m looking for file systems only.