Operating System - HP-UX
1752421 Members
5599 Online
108788 Solutions
New Discussion юеВ

Searching and replacing string

 
SOLVED
Go to solution
Jose Mosquera
Honored Contributor

Searching and replacing string

Hi pals,

I need search for the string 03 placed into 6th and 7th columns of the each line of a file. No all lines of the files have this condition. All lines of file must be displayed, changing just all the lines that fulfill the previous condition. Please use commands "sed" or "awk", omit perl.

Rgds
2 REPLIES 2
James R. Ferguson
Acclaimed Contributor
Solution

Re: Searching and replacing string

Hi:

# sed -e 's/\(^.\{5\}\)03/\1xx/' file

...for example, substitutes "xx" for "03" if "03" is in positions 6-7, one relative.

Regards!

...JRF...
Jose Mosquera
Honored Contributor

Re: Searching and replacing string

James, you got it!

Thank you very much.