Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just do it in Bash, of course! Take the poll andcopy/paste it directly into a file called 'hnpoll', then run

   sed -e ':a;N;$!ba;s/\n/ /g' -e 's/points/,/g' -e 's/point/ ,/g' -e  's/,/\n/g' hnpoll | awk '{ print $2 " "$1 }'  | sort -n | grep ^[0-9] | tail -n 20
12 Finland

12 Serbia

13 Norway

13 Romania

15 Belgium

15 Israel

15 Spain

16 Austria

19 Switzerland

20 Italy

21 India

22 Australia

22 Denmark

26 Brazil

26 Poland

35 Netherlands

36 Sweden

41 France

124 Germany

132 Canada

See- easy!

And if you want the US states, even easier:

    grep US -A1  hnpoll  | sed  -e ':a;N;$!ba;s/\n/ /g' -e 's/points/,/g' -e 's/point/ ,/g' -e 's/,/\n/g' -e '/^$/d' | sort -r |cut -d: -f2 | awk '{ print $2" "$1 }' | sort -n | tail -n 20
15 Arizona

16 Michigan

16 Minnesota

16 Ohio

16 Wisconsin

17 Maryland

18 Georgia

25 Florida

28 Jersey

31 Virginia

32 Pennsylvania

35 Oregon

39 Carolina

42 Illinois

47 Massachusetts

51 Colorado

59 Texas

103 Washington

110 New York

265 California

And people say Bash is a terrible language...

BUT WAIT THERE'S MORE!

Get the total number of US results:

   echo $(grep US -A1  hnpoll  | sed  -e ':a;N;$!ba;s/\n/ /g' -e 's/points/,/g' -e 's/point/ ,/g' -e 's/,/\n/g' -e '/^$/d' | sort -r |cut -d: -f2 | awk '{ print $2 }' | sort -n | grep ^[0-9] | paste -sd+ - | bc)" United States"
943 United States

Combine them a bit...

   sed -e ':a;N;$!ba;s/\n/ /g' -e 's/points/,/g' -e 's/point/ ,/g' -e  's/,/\n/g' hnpoll | awk '{ print $2 " "$1 }'  | sort -n | grep ^[0-9] | tail -n 20; echo $(grep US -A1  hnpoll  | sed  -e ':a;N;$!ba;s/\n/ /g' -e 's/points/,/g' -e 's/point/ ,/g' -e 's/,/\n/g' -e '/^$/d' | sort -r |cut -d: -f2 | awk '{ print $2 }' | sort -n | grep ^[0-9] | paste -sd+ - | bc)" United States"

12 Finland

12 Serbia

3 Norway

13 Romania

15 Belgium

15 Israel

15 Spain

16 Austria

19 Switzerland

20 Italy

21 India

22 Australia

22 Denmark

26 Brazil

26 Poland

35 Netherlands

36 Sweden

41 France

124 Germany

132 Canada

943 United States



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: