I need to replace the pattern ### with the current line number.
###
I managed to Print in the next line with both AWK and SED.
sed -n \"/###/{
This might work for you (GNU sed):
sed = file | sed 'N;:a;s/\(\(.*\)\n.*\)###/\1\2/;ta;s/.*\n//'