What would be the correct CL sequence to execute a df -h
and only print out the mount name and used space (percentage)? I'm trying to do a scripted report for our servers.
I tried
df -h | awk '{print $1 $4}'
which spits out
$df -h | awk '{print $1 $4}'
FilesystemAvail
/dev/sda164G
udev3.9G
tmpfs1.6G
none5.0M
none3.9G
none100M
/home/richard/.Private64G
How would you change this to add spacing? Am I selecting the right columns?
Try this:
df -h | awk '{if ($1 != "Filesystem") print $1 " " $5}'
Or just
df -h | awk '{print $1 " " $5}'
if you want to keep the headers.
You are almost there:
df -h | awk 'NR>1{print $1, $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