문제

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

도움이 되었습니까?

해결책

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.

다른 팁

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}'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top