Last active
August 29, 2015 14:05
-
-
Save peczenyj/68e51270c3ee25b607b0 to your computer and use it in GitHub Desktop.
Script que mostra quantas vezes um partido coliga com outro por estado
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Este script vai consultar o json da globo.com e vai mostrar em | |
# quantos estados o partido X coliga com os outros partidos | |
# | |
PARTIDO=${1:?favor informar o partido} | |
URL=http://estaticog1.globo.com/2014/07/Coligacoes/eleicao.json | |
echo "Coligações do partido $PARTIDO" | |
curl -s $URL | grep "\b${PARTIDO}\b" | cut -f 3 -d : | tr -d '" },\r' | tr ';' '\n' | grep -v "\b${PARTIDO}\b" | sort | uniq -c | sort -nr | awk 'function bar(x, A,i) { A = ""; for(i=0;i<x;i++) A = A "#" ; return A } { print $0,"\t", bar($1) }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./coligacoes.sh DEM | |
coligações do partido DEM | |
17 PSDB ################# | |
15 SD ############### | |
14 PSL ############## | |
14 PSC ############## | |
13 PPS ############# | |
13 PEN ############# | |
12 PV ############ | |
12 PSDC ############ | |
12 PR ############ | |
12 PMN ############ | |
11 PTN ########### | |
11 PTB ########### | |
11 PSD ########### | |
11 PRP ########### | |
10 PTC ########## | |
10 PMDB ########## | |
10 PHS ########## | |
9 PP ######### | |
8 PSB ######## | |
8 PRB ######## | |
8 PDT ######## | |
7 PTdoB ####### | |
7 PROS ####### | |
6 PRTB ###### | |
6 PCdoB ###### | |
4 PPL #### | |
3 PT ### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
P: mas pq o PCO não aparece? pq ele não coliga com nenhum outro partido.