For Programmers: Free Programming Magazines  


Home > Archive > Unix Programming > February 2008 > SED & FIXED WIDTH FILES









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SED & FIXED WIDTH FILES
kels

2008-02-11, 7:24 pm

I have limited exposure to sed and need to work with a fixed width
file with over 4 million records . I need to replace certain
characters based on the position the characters are found within each
record. I could awk to match the pattern using the following:
=83=DE awk 'substr($0,153,8)=3D=3D"94695577"'

How can I use this to replace the pattern with a new value.
William Pursell

2008-02-11, 7:24 pm

On Feb 11, 7:11 pm, kels <klintonse...@csc.com> wrote:
> I have limited exposure to sed and need to work with a fixed width
> file with over 4 million records . I need to replace certain
> characters based on the position the characters are found within each
> record. I could awk to match the pattern using the following:
> =83=DE awk 'substr($0,153,8)=3D=3D"94695577"'
>
> How can I use this to replace the pattern with a new value.


sed 's/^\(.\{152\}\)94695577\(.*\)/\1REPL\2/'

Should work.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com