Skip to main content
fix sed expression to add empty line (previous version added a line with a space)
Source Link

Using GNU sed -s (--separate) extension, you can append an empty newline after each filename (line addresses refer to each filename, instead of treating all the input as one longer stream, similar to awk's FNR and NR variables)

sed \
    -s \
    -e '$a\ ''$a\\' \
    -e 's/%%FOO%%/whatever/g' \
    -e 's/%%BAR%%/other thing/g \
    file1.ldif.template \
    file2.ldif.template \
    | ldapadd -x -D 'cn=admin,dc=example,dc=com' -W

So using -s with -e '$a\ ''$a\\' is what makes sed insert a newline at the end of all input files.

Using GNU sed -s (--separate) extension, you can append an empty newline after each filename (line addresses refer to each filename, instead of treating all the input as one longer stream, similar to awk's FNR and NR variables)

sed \
    -s \
    -e '$a\ ' \
    -e 's/%%FOO%%/whatever/g' \
    -e 's/%%BAR%%/other thing/g \
    file1.ldif.template \
    file2.ldif.template \
    | ldapadd -x -D 'cn=admin,dc=example,dc=com' -W

So using -s with -e '$a\ ' is what makes sed insert a newline at the end of all input files.

Using GNU sed -s (--separate) extension, you can append an empty newline after each filename (line addresses refer to each filename, instead of treating all the input as one longer stream, similar to awk's FNR and NR variables)

sed \
    -s \
    -e '$a\\' \
    -e 's/%%FOO%%/whatever/g' \
    -e 's/%%BAR%%/other thing/g \
    file1.ldif.template \
    file2.ldif.template \
    | ldapadd -x -D 'cn=admin,dc=example,dc=com' -W

So using -s with -e '$a\\' is what makes sed insert a newline at the end of all input files.

Source Link

Using GNU sed -s (--separate) extension, you can append an empty newline after each filename (line addresses refer to each filename, instead of treating all the input as one longer stream, similar to awk's FNR and NR variables)

sed \
    -s \
    -e '$a\ ' \
    -e 's/%%FOO%%/whatever/g' \
    -e 's/%%BAR%%/other thing/g \
    file1.ldif.template \
    file2.ldif.template \
    | ldapadd -x -D 'cn=admin,dc=example,dc=com' -W

So using -s with -e '$a\ ' is what makes sed insert a newline at the end of all input files.