Skip to content

Instantly share code, notes, and snippets.

@liweinan
Created August 4, 2023 18:07
Show Gist options
  • Save liweinan/0273f4b3e41ba6a9ea157153b9587a2f to your computer and use it in GitHub Desktop.
Save liweinan/0273f4b3e41ba6a9ea157153b9587a2f to your computer and use it in GitHub Desktop.
Using `sed` to add contents
weli@192:/tmp
➤ cat foo.txt 02:05:38
abc
def
weli@192:/tmp
➤ vi foo.txt 02:05:41
weli@192:/tmp
➤ sed -e 's/def/xyz/' foo.txt 02:05:48
abc
xyz
weli@192:/tmp
➤ sed -e 's/def/xyz\n/' foo.txt 02:05:51
abc
xyz
weli@192:/tmp
➤ sed -e 's/def/xyz\ndef/' foo.txt 02:05:55
abc
xyz
def
weli@192:/tmp
➤ 02:06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment