I am trying to write a bash script where I used awk to get a specific field.
Example:
# cat test.txt
USER NAME LOCATION
Frank China
Martin Indonesia
Tom Hanks United States
Ron Howard Germany
When I tried to take the first field using awk:
# cat test.txt | awk '{print $1}'
USER
Frank
Martin
Tom
Ron
But I want a conclusion like
Expected Result
#cat test.txt
USER NAME
Frank
Martin
Tom Hanks
Ron Howard
I even tried awk -F"\t" '{print $1 (or) $2}', but got only an empty output. I use this file in a while loop.
#cat test.txt | awk -F"\t" '{print $2}'
Any hints would be helpful.
source
share