I want to check whether if any column data has any + , - , = prefixed to it then convert it in such a form that in excel its not read as formula.
echo "$DATA" | awk 'BEGIN { OFS="," } -F" " {print $1,$2,$3,$4,$5,$6,$7,$8.$9,$10,$11,$12}'
I want to check whether if any column data has any + , - , = prefixed to it then convert it in such a form that in excel its not read as formula.
echo "$DATA" | awk 'BEGIN { OFS="," } -F" " {print $1,$2,$3,$4,$5,$6,$7,$8.$9,$10,$11,$12}'
Try this;
echo "$DATA" | sed "s/[[:space:]]\+/,/g;s/,\([-+=]\)/,\'\1/g"
Thanks , what if the data is null its coming as '
Try this...
echo "$DATA"| sed "s/^[[:space:]]*//;s/[[:space:]]\+/,/g;s/,\([-+=]\)/,\'\1/g"
What about this one
# echo '=1 2 3 4 -6 +5 2'|awk '{for(i=0;++i<=NF;){$i=($i !~ /^[+=-]/)?$i:"\""$i"\""}}1' OFS=\,
"=1",2,3,4,"-6","+5",2