I was using:
cat <<<"${MSG}" > outfile
to begin with writing a message to outfile
, then further processing goes on,
which appends to that outfile
from my awk script.
But now logic has changed in my program, so I'll have to first populate
outfile
by appending lines from my awk
program (externally called from my
bash script), and then as a final step prepend that ${MSG} heredoc
to
the head of my outfile
..
How could I do that from within my bash script, not awk script?
EDIT
this is MSG heredoc
:
read -r -d '' MSG << EOF
-----------------------------------------------
-- results of processing - $CLIST
-- used THRESHOLD ($THRESHOLD)
-----------------------------------------------
l
EOF
# trick to pertain newline at the end of a message
# see here: http://unix.stackexchange.com/a/20042
MSG=${MSG%l}
printf '%s\n' "$MSG" > outfile
. Avoid bashisms where you can. – Blitzkriegawk
, but, as thatawk
script gets called more than once from within my bash script, putting that MSG into BEGIN block wouldn't help, because I would have many instances, and I want only one at the top. – Eparchyl
trick for preserving trailing newlines if you instead use the following:IFS= read -r -d '' MSG << EOF ...
. – SpelldownIFS
value, or it doesn't matter, because it would go with the script being finished? – Eparchy