CSV data manipulation: Difference between revisions
→{{header|UNIX Shell}}
Line 4,108:
{{works with|bash}}
Very simple solution using powerfull and ancient but strong linux command, I named "tr" and "bc", and
<lang>cat csv | while read S; do
[ -z ${S##*C*} ] && echo $S,SUM || echo $S,`echo $S | tr ',' '+' | bc`
Line 4,114:
Result :
<lang>
1,5,9,13,17,45
2,6,10,14,18,50
Line 4,120:
4,8,12,16,20,60</lang>
Other solution (not from me) :
<lang>
exec 1>"$1.new" # open an output file on stdout
{
|