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 > Re: AWK & FIXED...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 2159 of 2297
Post > Topic >>

Re: AWK & FIXED WIDTH FILE to REPLACE VALUE

by Ed Morton <morton@[EMAIL PROTECTED] > Feb 11, 2008 at 01:30 PM

On 2/11/2008 1:21 PM, Kels wrote:
> I have limited knowledge of UNIX and a fixed witdth file of over 4
> million records. I need to match a pattern at a specific location in
> each record and replace the value. The following is an example of the
> awk I would use to find my pattern
> 
> ?	awk 'substr($0,153,8)=="94695577"'
> 
> How can I use this to replace the value.
awk
'substr($0,153,8)=="94695577"{$0=substr($0,1,152)"rep"substr($0,160)}1'
file

or with GNU awk:

awk --re-interval '{print gensub(/(.{152})94695577/,"\\1rep","")}' file

Regards,

	Ed.
 




 2 Posts in Topic:
AWK & FIXED WIDTH FILE to REPLACE VALUE
Kels <klintonselki@[EM  2008-02-11 11:21:42 
Re: AWK & FIXED WIDTH FILE to REPLACE VALUE
Ed Morton <morton@[EMA  2008-02-11 13:30:29 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Sun Jul 6 20:41:09 CDT 2008.