I am trying to treat a series of letters as an array in order to loop through each letter in a for loop, line by line, element by element.
My $data
after extracting a column looks something like:
ACACACACACA
CGCGCGCGGGG
TATATATAAAA
GAGAAAGAAGG
TGGTTTTGGTG
My script:
for j in `cat $data` # go line by line
do
for k in "${j[@]}" # go through each letter element by element
do
echo $k
done
done
Gives the output:
ACACACACACA
CGCGCGCGGGG
TATATATAAAA
...
I'd like the output to look like:
A
C
A
C
A
C
...
G
T
G
Is there something wrong with my syntax? Or is there a better way to call each element of the line?