bash - Consider the space between two strings using awk or any -


i'm trying write bash script used awk particular field.

example:

# cat test.txt user name    location frank        china martin       indonesia tom hanks    united states ron howard   germany 

when tried take first field using awk:

# cat test.txt  | awk '{print $1}' user frank martin tom ron 

but want output as

expected output

#cat test.txt user name frank         martin        tom hanks     ron howard  

i have tried awk -f"\t" '{print $1 (or) $2}', got blank output. i'm using file in while loop.

 #cat test.txt  | awk -f"\t" '{print $2}' 

any hint helpful.

you can use delimiter 2 or more spaces:

awk -f ' {2,}' '{print $1}' file  user name frank martin tom hanks ron howard