I have a command that outputs three lines like this:
L1
L2
L3
I need to append each of those lines into a data file for Gnuplot, where there is no “comment block”, and thus you can only prepend the “#” symbol to each line. I’m scripting this whole process in bash, how do I substitute a \n for \n# in bash?
Try and pipe your command through sed like this:
It will replace the first character of first line with # followed by said character.
If you also want to get stderr, then throw stderr into stdout first like this:
EDIT: thanks @ДМИТРИЙ МАЛИКОВ ! I just leadend something new. I’ve updated my blocks with your even shorter expression