[SOLVED] awk split shows nothing
by vincix from LinuxQuestions.org on (#52HCR)
Can anyone help me to understand why this works?
Code:df -h | awk '/Mounted on/{ split($6,a," "); print a[1]}'
MountedBut this outputs nothing?
Code:df -h | awk '/Mounted on/{ split($6,a," "); print a[2]}'I would have expected to show 'on'.
This, on the other hand, works, if applied on the whole line:
Code:df -h | awk '/Mounted on/{ split($0,a," "); print a[7]}'
on


Code:df -h | awk '/Mounted on/{ split($6,a," "); print a[1]}'
MountedBut this outputs nothing?
Code:df -h | awk '/Mounted on/{ split($6,a," "); print a[2]}'I would have expected to show 'on'.
This, on the other hand, works, if applied on the whole line:
Code:df -h | awk '/Mounted on/{ split($0,a," "); print a[7]}'
on