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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field delimiter

Status
Not open for further replies.

mbach

Technical User
Dec 12, 2000
24
0
0
US
All,

How can I make the field delimiter be more than one character in awk? I would like to make it (WIN32.

Thanks
Mike
 
I've only ever used one character or \t
Have you tried :
awk '
BEGIN {
FS="(WIN32"
}

Vlad will know - he always does ! :)

Dickie Bird (:)-)))
 
You can set the field separator to multiple characters, but because it is a regular expression, the ( needs to be escaped. There are a number of ways to do this, one of which is

FS="[(]WIN32"

CaKiwi

"I love mankind, it's people I can't stand" - Linus Van Pelt
 
FS="\\(WIN32"

You need to 'double-escape' the parentheses as it's to be taken literary. The FS is a regex and '()' are used for grouping with OR:

FS="(abc)|(def)"
an FS is EITHER 'abc' OR 'def'

Hey, dickie! :)

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
<modestyOFF>
what can I say - great minds think alike
</modestyOFF>

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
<modestyON>
Stop, stop, you're embarassing me [blush]
</modestyON>

CaKiwi

&quot;I love mankind, it's people I can't stand&quot; - Linus Van Pelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top