I have a little QSHELL script that reads a csv file, does some formatting on each word and puts it back into a csv file... sort of.
When I try to append the $WORD to the current line it works fine except when I use a comma. For example this works
This does not output ,
I am guessing it has something to do with the csv file I am reading since this works fine
Here is the script if that helps
When I try to append the $WORD to the current line it works fine except when I use a comma. For example this works
Code:
ln=${ln}'comma'${WORD}
Code:
ln=${ln}','${WORD}
Code:
r=dog s=food r=$r,$s echo $r
Code:
IFS=, ###REMOVE EXISTING FILE echo '' >> $2 while read LINE do ln="" for WORD in $LINE do mb=0 ##FORMAT IND db=0 ##FORMAT IND case $WORD in *\/*) ##GET MONTH m=${WORD:0:2} ##FORMAT MONTH IF NEEDED case $m in *\/*) m=0${m:0:1} mb=1 ;;esac ##GET DAY if [[ $mb -eq 1 ]] then d=${WORD:2:2} else d=${WORD:3:2} fi ##FORMAT DAY IF NEEDED case $d in *\/*) d=0${d:0:1} db=1 ;;esac ##GET FULL DATE BASED ON OFFSETS if [[ $mb -eq 1 -a $db -eq 1 ]] then WORD=${m}"/"${d}"/"${WORD:4} elif [[ $mb -eq 0 -a $db -eq 0 ]] then WORD=${m}"/"${d}"/"${WORD:6} else WORD=${m}"/"${d}"/"${WORD:5} fi ;;esac if [ -n "$ln" ] then ln=${ln}'a,'${WORD} else ln="$WORD" fi done echo $ln'\n' >> $2 done < $1 ###$1 is input file
Comment