Skip to content

Instantly share code, notes, and snippets.

@nordurljosahvida
nordurljosahvida / bash sed insert file contents between two matches
Last active April 20, 2019 14:13
bash sed insert file contents between two matches
### Delete everything between the HEAD and TAIL lines in FILE_TO_EDIT
sed -i '/HEAD_LINE_CONTENT/,/TAIL_LINE_CONTENT/{//!d}' /path/of/file/to/edit
### Insert entire contents of FILE_TO_INSERT inside FILE_TO_EDIT after HEAD line
sed -i "/HEAD_LINE_CONTENT/ r /path/of/file/to/insert" /path/of/file/to/edit

Keybase proof

I hereby claim:

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am nikksno on github.
* I am nikksno (https://keybase.io/nikksno) on keybase.
* I have a public key ASAf0Pukj7bd71nEumCDSodKfR5WMWEOSajFMiPjAhzoUQo
To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am nikksno on github.
  • I am nikksno (https://keybase.io/nikksno) on keybase.
  • I have a public key whose fingerprint is 95C6 DA77 4B16 DA19 902A 20F0 C355 8165 357A B55A

To claim this, I am signing this object: