# Need Generic command for disk space usage

**URL:** <https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217>\
**Category:** Shell Programming and Scripting\
**Created:** [August 29, 2016, 4:04pm UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217 "2016-08-29T16:04:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohtashims](https://community.unix.com/letter_avatar/mohtashims/32/6_449c533f586939b6e5f246632a46421f.png) [@mohtashims](https://community.unix.com/u/mohtashims)\
**Post date:** [August 29, 2016, 4:04pm UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/1 "2016-08-29T16:04:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Don\_Cragun](https://community.unix.com/user_avatar/community.unix.com/don_cragun/32/2682_2.png) [@Don\_Cragun](https://community.unix.com/u/Don_Cragun)\
**Post date:** [August 29, 2016, 8:41pm UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/2 "2016-08-29T20:41:35Z")

</div>

What output do you get from:

```nohighlight
df -Ph /web

```

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

What output do you get from the commands:

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

```

and:

```nohighlight
df -h /web

```

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

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_449c533f586939b6e5f246632a46421f.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [August 30, 2016, 5:29am UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/3 "2016-08-30T05:29:14Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![mohtashims](https://community.unix.com/letter_avatar/mohtashims/32/6_449c533f586939b6e5f246632a46421f.png) [@mohtashims](https://community.unix.com/u/mohtashims)\
**Post date:** [August 30, 2016, 6:16am UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/4 "2016-08-30T06:16:24Z")

</div>

You are such an Amazing expert ...

`df -Ph` resolved the issue.

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

---

<div class="post-metadata">

**Author:** ![MadeInGermany](https://community.unix.com/letter_avatar/madeingermany/32/6_449c533f586939b6e5f246632a46421f.png) [@MadeInGermany](https://community.unix.com/u/MadeInGermany)\
**Post date:** [August 30, 2016, 1:41pm UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/5 "2016-08-30T13:41:38Z")

</div>

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

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

```

Print the 5th field without the % sign

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

```

---

<div class="post-metadata">

**Author:** ![mohtashims](https://community.unix.com/letter_avatar/mohtashims/32/6_449c533f586939b6e5f246632a46421f.png) [@mohtashims](https://community.unix.com/u/mohtashims)\
**Post date:** [August 30, 2016, 6:19pm UTC](https://community.unix.com/t/need-generic-command-for-disk-space-usage/362217/6 "2016-08-30T18:19:39Z")

</div>

> [@rudic](#):
>
> 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...

I m looking for file systems only.
