Sometimes, when we modify the configuration file, we need to specify certain regions where sed cannot be modified. For example:
Sed-e '2017 S/okay now // G'-e '2017, $ S/okay now // G' config_file
We noticed that rows 101st to 199th were ignored by sed.
We also note that here S // is used to replace the expression. If you use the delete statement, for example, // D, it must be placed in the braces ." // A \ "add is the same! For example:
Sed-e '2017 {/okay now/d} '-e '2017, $ {/okay now/d}' config_file
2. If we do not know the exact row number, but only the keyword, we can use "/keyword/" to replace the row number, for example:
Sed-e '^,/Okay No/{/okay now/d}-e' ^,/Okay No/{/Okay No/A \ Okay now} 'config_file
This expression deletes okay now from the beginning to okay no, and adds okay now again after Okay No.
Sed: how to limit the modification range?