I'm trying to stick the text output of a linux command into a single cell of a csv file. No matter how I try to escape quotes, the newline characters do not seem to be registered by the csv file.
For example if the output of one of these commands is:
155 C T
2518 T C
It is being printed within the csv cell as:
155 C T 2518 T C
for filename in "$1"/*JGI*.vcf; do
counter=$((counter + 1))
depth_score="$(samtools depth "${filename%.*}.bam" | python depth.py)"
variant_array="$(bcftools query -f '%POS %REF %ALT\n' "$filename")"
column_name="$(basename "$filename")"
echo "$counter/$total_colonies" # echo current/total
echo "$variant_array"
echo ""$variant_array""
echo "$column_name, "$variant_array", $depth_score" >> output.csv
done
Here is the for loop that's giving me some errors.
The result of the $variant_array is the problem.
I have two print logs above where I write to the output.csv to see what's going on.
"$variant_array" yields the desired behavior, but for some reason when I echo that within another set of quotes to write it to the csv file, it ignores the newlines...