I try to use sed to insert a line after [Block B] in the following file:
[Block A]
line 1
line 2
[Block B]
line 1
line 2
[Block C]
line 1
line 2
The command I used:
sed '/\[Block B\]/,/^$/a\inserted line' file
The correct/desired result should be:
[Block B]
line 1
line 2
inserted line
However, I got this instead:
[Block B]
inserted line
line 1
inserted line
line 2
inserted line
Please tell me how I can get the desired result using sed. Thanks!
1 Answer