Last active
August 16, 2021 08:19
Star
You must be signed in to star a gist
[Sed Replace Pattern with File Contents] #sed #bash #replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd -- "$(mktemp -d)" | |
printf '%s\n' 'nuts' 'bolts' > first_file.txt | |
printf '%s\n' 'foo' 'bar' 'baz' > second_file.txt | |
sed -e '/bar/r ./first_file.txt' second_file.txt | |
### output... | |
foo | |
bar | |
nuts | |
bolts | |
baz | |
### ...notice 'bar' in second_file.txt has the contents from first_file.txt appended after it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment