What I want to do is extract the fourth column with awk, however, there are some blank space in some field. I get wrong result when it print out awk result.
awk '{print $1,$4}' awk_column_test.txt
How will i deal with these blank spaces?
If I want print 'NULL' when the field is blank, how will I should do?
This input file is worse than any of you seem to have imagined. This file uses <space> as the field separator and uses <space> as the contents of an "empty" field. Since the field separator is also field contents in some cases, there is no obvious way to specify an ERE that matches just the field separators. The following awk script converts the spaces that are data to the string "NULL" and leaves the spaces that are separators alone. It seem to do what was requested. (Note that the 2nd printf statement just shows how the input is modified along with the desired output. Remove it to just get the desired output.)