I have a variable in a shell script in which I’d like to format the data. The variable stores new data during every iteration of a loop. Each time the new data is stored, I’d like to insert a new line character. Here is how I’m trying to store the data into the variable.
VARIABLE="$VARIABLE 'n' SomeData"
Unfortunately, the output includes the literal 'n'
Any help would be appreciative.
Advertisement
Answer
Try $'n'
:
VAR=a VAR="$VAR"$'n'b echo "$VAR"
gives me
a b