Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
cat csv | while read S; do
[ -z ${S##*C*} ] && echo $S,SUM || echo $S,`echo $S | tr ',' '+' | bc`
done

View file

@ -0,0 +1,5 @@
C1,C2,C3,C4,C5,SUM
1,5,9,13,17,45
2,6,10,14,18,50
3,7,11,15,19,55
4,8,12,16,20,60

View file

@ -0,0 +1,20 @@
bash>exec 0<"$1" # open the input file on stdin
exec 1>"$1.new" # open an output file on stdout
{
read -r header
echo "$header,SUM"
IFS=,
while read -r -a numbers; do
sum=0
for num in "${numbers[@]}"; do
(( sum += num ))
done
# can write the above loop as
# sum=$(( $(IFS=+; echo "${numbers[*]}") ))
echo "${numbers[*]},$sum"
done
} &&
mv "$1" "$1.bak" &&
mv "$1.new" "$1"