bash - add blank line to heredoc via variable
Clash Royale CLAN TAG #URR8PPP up vote 0 down vote favorite If I am using this scenario in a script: #!/bin/bash addvline=$(if [ "$1" ]; then echo "$1"; echo; fi) cat << EOF this is the first line $addvline this is the last line EOF if $1 is emty I get a blank line. But how can I add a blank line after $1 for the case it is not emty? So in the case running the script like: bash script.sh hello I would get: this is the first line hello this is the last line I tried to achieve this with using a second echo in the if statement , but the newline does not get passed. bash variable cat here-document share | improve this question asked Oct 1 '17 at 16:23 nath 633 4 21 add a comment  | up vote 0 down vote favorite If I am using this scenario in a script: #!/bin/bash addvline=$(if [ "$1" ]; then echo "$1"; echo; fi) cat << EOF this is the first line $addvline this is the ...