Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

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}'
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top