I am having some hard time with awk today. If I try to do:
df|awk '{print $2; $some=$2; print $some}'
It works as expected and I get the size of the disks twice but if I do:
df|awk '{$some=$2; print $some}'
I just get blank lines. Why is this happening? Something is maybe wrong in my understanding but why the usage of a field mandatory for subsequent fields to work? I also tried doing:
df|awk '{print "hello"; $some=$2; print $some}'
and I got some "hello", each separated by a newline. Where is $some=$2 lost?
My df command outputs:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda5 38448788 32098732 4396932 88% /
udev 1914564 4 1914560 1% /dev
tmpfs 768744 984 767760 1% /run

$someinawkmeans field number some. (e.g. if some=13, then $some means 13th field) – manatwork Mar 8 at 10:57