I have a disk mounted on /dev/xxx. If I use only df, it returns this:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/xxx 125829120 43861888 81967232 35% /
devtmpfs 4194304 0 4194304 0% /dev
...
I need to get only:
a) number of 1K-blocks
b) used space
How to do that?
df /dev/sda1 --output=source,size,used
...gives a terse summary.
ACCEPTED]
Here you go
df /dev/xxx | awk 'END { print $2, $3 }'
Using awk , if you want to do some process inside the block .
For only number of K-blocks and used space :
df | awk 'BEGIN { getline } { print $2,$3 }'
If you want With Filesystem name :
df | awk 'BEGIN { getline } { print $1,$2,$3 }'
For only the disk /dev/xxx
df /dev/xxx | awk 'BEGIN { getline } { print $2,$3 }'
/dev/xxx. You have/dev/xxxmounted on/. - Kusalananda