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.


|