Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 529  / 3 Years ago, fri, may 7, 2021, 2:25:32

I want from the output below grab all the volume names that have a capacity over 85%. I know that there isn't one in ths example but lets pretend there is. :)



Filesystem               total       used      avail capacity  Mounted on
/vol/mc3240a/ 190GB 18GB 171GB 10% /vol/mc3240a/
/vol/mc3240a/.snapshot 10GB 355MB 9884MB 3% /vol/mc3240a/.snapshot
/vol/mc3240b_root_backup/ 210GB 9019MB 201GB 4% /vol/mc3240b_root_backup/
/vol/mc3240b_root_backup/.snapshot 0MB 1691MB 0MB ---% /vol/mc3240b_root_backup/.snapshot

More From » bash

 Answers
7
df -h | egrep "(8[5-9]|9[0-9]|100)%" | cut -f 1 -d " "



  • This will catch 85% up to 100% (the 0, does the {1}00%)

  • The cut will show the 1st column (anything after the 1st space in the output is deleted; a device can not have a space)



Examples:



Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1 139G 132G 218M 100% /
varrun 2.0G 368K 2.0G 1% /var/run
varlock 2.0G 0 2.0G 0% /var/lock
udev 2.0G 48K 2.0G 1% /dev
devshm 2.0G 0 2.0G 0% /dev/shm

$ df -h | egrep "(8[5-9]|9[0-9]|100)%" | cut -f 1 -d " "
/dev/sda1

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 144G 130G 7.5G 95% /
varrun 506M 148K 506M 1% /var/run
varlock 506M 4.0K 506M 1% /var/lock
udev 506M 72K 506M 1% /dev
devshm 506M 0 506M 0% /dev/shm
$ df -h | egrep "(8[5-9]|9[0-9]|100)%" | cut -f 1 -d " "
/dev/sda1

[#26938] Sunday, May 9, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
saucdisr

Total Points: 4
Total Questions: 102
Total Answers: 117

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
;