There is no such thing as an "empty" column in awk processing by default.
Fields are separated by a space, that is, one or more white space characters (mainly tabs and spaces). Therefore, given this input:
this that the_other foo bar
for the first line $1 , $2 and $3 are this , that and the_other , respectively, but for the second line of bar there is $2 , regardless of how many spaces are between the first and second fields.
You may have empty fields if you specify a different field separator:
$ ( echo 'this:that:the_other' ; echo 'foo::bar' ) | awk -F: '{print $3}' the_other bar
Or, if you prefer to set the field separator in the script itself:
$ ( echo 'this:that:the_other' ; echo 'foo::bar' ) | \ awk 'BEGIN { FS = ":" } {print $3}' the_other bar
But you can use regex as a field separator:
$ ( echo 'this that the_other' ; echo 'foo bar' ) | \ awk 'BEGIN { FS = "[ ]" } {print $3}' the_other bar
(Some very old implementations of Awk may not support its regular expressions here.)
The regular expression "[ ]" does not receive the same special treatment as the space character.
Links to the GNU Awk manual:
The default field separation is :
Fields are usually separated by whitespace (spaces, TAB, and newlines), rather than single spaces. Two spaces in a row do not separate the blank field. The default value of the FS field delimiter is the string containing one space, " " . If awk interprets this value in the usual manner, each spatial character will separate the fields, so two spaces in the line will make an empty field between them. The reason for this does not happen, because one space as the FS value is a special case - it is customary to specify the default demarcation mode of the field.
If FS is any other single character, such as "," , then each occurrence of this character separates the two fields. Two consecutive events divide an empty field. If the character occurs at the beginning or at the beginning of the end of the line, this also limits the empty field. The cosmos symbol is the only single symbol that does not follow this rule.
and Using regular expressions to separate fields .
But be careful with this; either you have to modify the file to use a different separator, or your parsing will be sensitive to the number of spaces between the fields ( foo bar (with one space) will be different from foo bar (with two spaces)).
Depending on your application, you might consider parsing rows by column number rather than awk signs.