Skip to content

Instantly share code, notes, and snippets.

@hrpunio
Created May 8, 2013 13:39
Show Gist options
  • Save hrpunio/5540475 to your computer and use it in GitHub Desktop.
Save hrpunio/5540475 to your computer and use it in GitHub Desktop.
#!/usr/bin/awk -f
# Podsumowanie gw. kategorii
# Wykonanie awk -f foo2.awk co='wartosc' plik
#
BEGIN {
sub("^:","#>", co); sub(":$","#<", co);
gsub(":",":[^:]*:", co);
sub("^#>",":", co); sub("#<$",":", co);
print "Szukam: " co ; }
$0 ~ /<<month>>/ { if (sum > 0 ) {mn++; M[ mn " : " cm ] = summ ; summ = 0; };
cm = $3; next }
$0 ~ co {sum +=$1 ; summ+=$1; print $0 " ; " cm ;}
END { print "Razem: " sum }
END {
print "Miesiace: "
for ( m in M ) {
print m " : " M[m] | " sort -n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment