Not sure about csh, but as far as I know arrays in bash, sh and ksh can only be indexed by integers, so you have to approach it differently... try this perhaps:
Code:
tot=0
n=0
sort -t';' -k 1,1 -k 2,2 /input/file | while IFS=';' read a b c d e f g
do
if [[ "$prev" != "" && "$a;$b" != "$prev" ]]
then
echo "$prev:$n;$tot"
tot=0
n=0
fi
((n=n+1))
((tot=tot+$g))
prev="$a;$b"
done
echo "$prev:$n;$tot"
Incidentally, I think there's an error on the second line of your awk script; shouldn't the index of l have a semi-colon too, rather than a colon?
If you want associative arrays in [tt]bash[/tt], take a look at the libbash project. Its install package contains a library, hashstash. That may help you.
( Note, that I never used it so I know nothing more about it. I just suppose it can be quite slow as it is based on [tt]eval[/tt]. )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.