I have a csv composed as follows:
Column1,Column2,Column3
A Existing text in Column1, A Date in Column2, A Integer in Column3
B Existing text in Column1, B Date in Column2, B Integer in Column3
C Existing text in Column1, C Date in Column2, C Integer in Column3
I'm trying to save each line as a variable with a for Loop as it iterates through the file:
for i in `cat file.csv`
do
VARIABLE=$(echo $i && echo ", Another text")
done
Instead of the variable being saved as (e.g. VARIABLE through first iteration):
A Existing text in Column1, A Date in Column2, A Integer in Column3, Another text
It's saving as:
Column1,Column2,Column3
, Another Text
A
, Another Text
Existing
, Another Text
text
, Another Text
in
, Another Text
Column1,
, Another Text
A
, Another Text
Date
, Another Text
in
, Another Text
Column2,
, Another Text
A
, Another Text
Integer
, Another Text
in
, Another Text
Column3
, Another Text
B
, Another Text
Existing
, Another Text
text
, Another Text
...(continues)
Is there a specific reason why the for loop is braking each work instead of just treating the entire line as a whole?