shell - bash/sed - Search a line, change it and copy it below the found line -


I am looking for an easy method to replace multiple lines in a file, edit them and find the bottom line Copy them. / P>

Example before editing:

  ... # - # Parents Hostname ... ... # - # Guardian hostname ... ...  

How should the example be edited after editing:

  ... # - # Parents hostnames_parents hostnamexy ... ... # - # Parents Hostname: _parents hostnameyz. ..  

I did not want to write a big shell script to do this and thought it is possible? With Sed?

Thank you for your help!

Greetings Matte

  sed '/ # - # parent / {P; S / # - # / _ /;} ' 

All strings are printed, but when we have # - # parent Prints the string, then makes the replacement automatic print emits the prescribed version.

IHTH


Comments