Q:

write a number of strings using awk

I have data in text in a 4 columns but the last column is a text (contains variable strings) like as shown below
Column1 Column2 Column3 Column4
5678    567     56      hello
1234    123     12      hello there

I want to write or display only the 4th column using awk like:
awk '{print $4}' but column4 only shows the first string.
How can I be able to show text using awk or any other formatting command.
Thanks.

A:

I think the easiest way is probably a mix of tr (to ensure there's only one space between each column) and cut to grab the 4th and subsequent columns:
$ cat test.txt | tr -s ' ' | cut -f 4- -d ' '
Column4
hello
hello there

If you're certain that all the columns are alligned, with spaces (not tabs), then this is shorter:
$ cut -c 25- < test.txt
Column4
hello
hello there

And the obligatory awk solution:
$ awk '{ $1=$2=$3=""; print $0 }' < test.txt
   Column4
   hello
   hello there

Note the whitespace at the start of each line of output, compared to the previous two solutions.

