-3

I'm writing a bash script where I need to print out the content of Available in /home. So in the below example, it would be 458G. I was thinking maybe I can use grep or awk and then print $3 or something like that? I'd appreciate the help here! I'm new to bash script.

**Filesystem          1G-blocks  Used Available Use% Mounted on**

/dev/mapper/cl-root       50G   28G       23G  55% /
devtmpfs                  48G    0G       48G   0% /dev
tmpfs                     48G    1G       48G   1% /dev/shm
tmpfs                     48G    1G       47G   1% /run
tmpfs                     48G    0G       48G   0% /sys/fs/cgroup
/dev/sda2                  1G    1G        1G  45% /boot
/dev/sda1                  1G    1G        1G   5% /boot/efi
/dev/mapper/cl-home      492G   34G      458G   7% /home
tmpfs                     10G    1G       10G   1% /run/user/1000

3 Answers3

1

Specify /home as an argument to df.

df /home
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
0

df -h | grep /home | awk '{print $4}' will give you Available field for /home

dejanualex
  • 3,872
  • 6
  • 22
  • 37
0

This question has nothing to do with bash. Since it has a linux tag, then simply:

df -h --output=avail /home | tail -n1
M. Nejat Aydin
  • 9,597
  • 1
  • 7
  • 17