I am trying to create a TSV file from an array that I build inside a loop. I do get the values on each line to be tab separated, but I am not able to export each element of the array on a new line. This is an example:
OUTPUT=()
#header
OUTPUT+=$(printf "col_1\tcol_2\tcol_3")
param_1="bla"
param_2="tra"
param_3="meh"
for i in 1 .. 3
do
OUTPUT+=$(printf "$param_1\t$param_2\t$param_3")
done
#export
printf '%s\n' "${OUTPUT[@]}" > test.tsv
I have also tried to put \n at the end of each string that I insert in the array, but it did not work. Any idea what I am doing wrong? Thank you
awkor other dedicated tools. If I need to get something more complex done, then of course I would use something more appropriate. I just needed to write a script to be in line with the other existing scripts and not use a different programming language/tool just for a simple task