regex - matching ranges in sed -


I need sed in my program, some files need to change some letters with each other. But some words And only if this string contains some additional words, so I wrote:

  sed -re '/ from: /, / end / {/ extraword / s / [_ old_characters _] / new_character / g; } '  

but this code ignores the total / to: /, / end / string [_ old_characters_] Starts with new_character with : and at the end of this line. what did I do?

What do I need:

  sed -re / a /, / b / {/ word / s / [c] / x / g; } '  

File:

  The word CCC becomes a CCC BCCC wor A CCC B   

:

  The word ccc is a xxxb ccc wor a ccc b    

This can work for you (GNU sed):

  sed -r '/ word / {: a; / (A) ([^ ABC] * C + [^ ABC] *) (b) / {s / \ 1 \ n \ 2 \ n \ 3 /; H; y / c / x /; G ... (*) \ N * \ n (*) This filter line in which the term  words  and  A    

After C followed by B

/ code>. In such lines, the markers ( \ n 's) are placed before the a and b and hold a copy of the line Is kept (HS). All are replaced with the C of X and then the copy in HS is linked to the modified line and both are rebuilt from the required line, then the new line is tested And if necessary, the process is repeated.

Use the same technique if you have the A and B words, but after the option \ n A and before b first, then / \ n * * c. * \ N /

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -