Sh grouping contents of a csv file

6 views
Skip to first unread message

Go Phone

unread,
Jan 14, 2022, 3:22:33 PMJan 14
to inferno-os
Hello,

I am trying to figure out how to do grouping with Sh (similar to awk
'{total+=$2};END {print total}').

This is my Sh script and output : http://okturing.com/src/12979/body

Any suggestions?

Thanks

% cat gtest
#!/dis/sh

load std csv

nums=()
fn groupcontents {
(fld1 fld2)=$*
echo $fld2
nums=$nums $fld2
echo $nums
}

{
echo a,1
echo b,2
echo c,3
} | getcsv {groupcontents $line }

echo end of file: $nums
% ./gtest
1
1
2
1 2
3
1 2 3
end of file:
%
Reply all
Reply to author
Forward
0 new messages