difference awk print $1, .. $NF and print $0

echo "a b c  d" | awk '{print}'

or

echo  "a b c  d" | awk '{print $0}'

returns a b c d.

echo "a b c  d" | awk '{print $1, $2, $3, $4}'

returns a b c d

Are there any ways to simply do $1, $2, $3, $4 as $hoge alternatively.


In case of echo "a b c d" |awk '{print}' (or {print $0}) the record $0 does not get rebuilt but is outputed as is. If you'd like it rebuilt:

$ echo "a b c  d" |awk '{$1=$1; print}'
a b c d

https://www.gnu.org/software/gawk/manual/html_node/Changing-Fields.html:

It is important to remember that $0 is the full record, exactly as it was read from the input. This includes any leading or trailing whitespace, and the exact whitespace (or other characters) that separates the fields.