Frage

How can extract only "name" and "available space" from df linux command.

War es hilfreich?

Lösung

You can use...

df | tail -n +2 |  awk '{ print $1, $4 }' 

...assuming you don't want the headers too. If you do, remove the tail.

We are piping df's output into tail, where we cut the first line off (the headers), and then pipe that into awk, using it to print the first and fourth columns.

Andere Tipps

Assuming name and available space are 1st and 4th columns:

 df | awk '{print $1, $4}'

the traditional approach would be

df | awk '{printf "%-15s%-8s\n",$1,$5}'
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top