I am trying to get a specific line using awk command.
When i do df -h, i get :-
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 2.7M 3.2G 1% /run
/dev/nvme0n1p2 468G 64G 381G 15% /
tmpfs 16G 77M 16G 1% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/loop0 100M 100M 0 100% /snap/core/11420
/dev/loop2 56M 56M 0 100% /snap/core18/2074
Using df -h | awk '{print $2, $3, $4, $5}' gives me the following output :-
Size Used Avail Use%
16G 0 16G 0%
3.2G 2.7M 3.2G 1%
468G 64G 381G 15%
16G 80M 16G 1%
5.0M 4.0K 5.0M 1%
16G 0 16G 0%
How can i only get the contents from anything associated with "/" partition whether only using awk or maybe some other command?
One awk way would be to filter on field 6. Perhaps:
df -h | awk '$6=="/" {print $2, $3, $4, $5}'
Alternatively, you could tell df to only show /:
df -h / | awk '{print $2, $3, $4, $5}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With