Since /r means reading in a file, use:
sed '/First/r file1.txt' infile.txt
You can find the information here: Reading in a file with the "r" command .
Add -i (i.e. sed -i '/First/r file1.txt' infile.txt ) to post in-place.
To perform this action, regardless of the case with characters, use the I sign, as suggested in Use sed with ignore when adding text before some pattern :
sed 's/first/last/Ig' file
As stated in the comments, the above solution simply prints the given line after the pattern, not taking into account the second pattern.
To do this, I would select awk with the flag:
awk -v data="$(<patt_file)" '/First/ {f=1} /Second/ && f {print data; f=0}1' file
Given these files:
$ cat patt_file This is text to be inserted $ cat file Some Text here First First Second Some Text here First Bar
Run the command:
$ awk -v data="$(<patt_file)" '/First/ {f=1} /Second/ && f {print data; f=0}1' file Some Text here First
fedorqui
source share