I have a set of files with file extension ovpn and wish to insert into each of them the following three lines: The above are to be placed after this line: The desired output should be: My attempt is: Code: sed -i -e '/auth SHA512/a\' \ -e '\n\nscript-security 2\nup /etc/openvpn/update-resolve-conf\ndown /etc/openvpn/update-resolv-conf\n' \ *.ovpn However the above commands add two blank lines after "auth SHA512" and a blank line after "down /etc/openvpn/update-resolv-conf". Can someone show me how to not add blank lines after "auth SHA512" and a blank line after "down /etc/openvpn/update-resolv-conf"?