Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,3 @@
|
|||
cat csv | while read S; do
|
||||
[ -z ${S##*C*} ] && echo $S,SUM || echo $S,`echo $S | tr ',' '+' | bc`
|
||||
done
|
||||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue