Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

awk FS of 2 or more spaces

Status
Not open for further replies.

Hemo

Programmer
Apr 9, 2003
190
US
I have a file that has fields separated by two or more space characters. Some of the fields contain a single space.

I'm puzzled how I could get awk to recognize 2 or more spaces as the field separator.

awk -F " " doesn't do it for me.

Given this data:
record1 record2 this is record three record4

I am trying to get this result:
field1=record1
field2=record2
field3=this is record three
field4=record4

Ideas?
 
Code:
nawk -F' {2,}'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
figures as soon as I post I figure it out.

I had bee trying this as well:
awk -F "[ ]+"

but this is what ended up working:

awk -F "[ ]+[ ]+"
 
I would use awk -F ' +'. There's no need for the square brackets when you are only specifying one character.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top