The sample input is123456789The expected output is123---45---678---9
How to replace multiple blank lines with a specific non-blank line?
sed;awk
One way:cat -s file | sed 's/^$/---/'From man page of cat :   -s, --squeeze-blank          never more than one single blank lineOnce cat has squeezed the blank lines, sed replaces the blank with with a ---