0

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?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
rktech
  • 59

3 Answers3

2
df /dev/sda1 --output=source,size,used

...gives a terse summary.

JRFerguson
  • 14,740
1

Here you go

df /dev/xxx | awk 'END { print $2, $3 }' 
GMaster
  • 6,322
0

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 }'