Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Changing FS int...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 2087 of 2317
Post > Topic >>

Changing FS inter-record

by james19390@[EMAIL PROTECTED] Dec 1, 2007 at 11:19 AM

Is there a way for awk to change FS *before* it processes a record?
In the following example, I want awk to change FS whenever the
beginning of the record matches certain characters:

$ cat file1
#field1,field2,field3
#field1,field2,field3,field4
#field1,field2
@[EMAIL PROTECTED]
 awk '/^#/{FS=",";print $1}/^@[EMAIL PROTECTED]
";";print $1}' file1
#field1,field2,field3
#field1
#field1
@[EMAIL PROTECTED]
 you can see FS does change, but not until after the first matching
record has been processed using the previous  FS.
 




 4 Posts in Topic:
Changing FS inter-record
james19390@[EMAIL PROTECT  2007-12-01 11:19:55 
Re: Changing FS inter-record
"Radoulov, Dimitre&q  2007-12-01 21:18:16 
Re: Changing FS inter-record
Cesar Rabak <csrabak@[  2007-12-01 18:30:49 
Re: Changing FS inter-record
james19390@[EMAIL PROTECT  2007-12-01 16:31:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:20:10 CDT 2008.