sed: append string to the end of the matching line

  • The orginal file file.txt:
    abc
    cde
    efg
  • Apend 123 to the line: cde. The expected result text should be:
    abc
    cde 123
    efg
  • The sed command:
    sed '/^cde/ s/$/ 123/' file.txt

No comments:

Post a Comment