Search code examples
linuxbashubuntuawktext-processing

How to limit the result of the quota command in bash


I have a simple question but i didn't find a method to implement it, in case I need to get only the free space value of the quota command.

Scenery: $ quota -s abdalazizdemoura Result:

Disk quotas for user abdalazizdemoura (uid 3944):
     Filesystem   space   quota   limit   grace   files   quota   limit   grace
/dev/mapper/work-home
                  5068M      0K   5120M            246k       0       0
/dev/mapper/work-lxc
                   828K      0K  20480K              26       0       0

I specifically need the output of /dev/mapper/work-home partition to space or limit and nothing else.


Solution

  • Like this?

    quota -w -s abdalazizdemoura | awk '/\/dev\/mapper\/work-home/ {print $2}'
    5068M
    quota -w -s abdalazizdemoura | awk '/\/dev\/mapper\/work-home/ {print $4}'
    5120M