Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created August 2, 2014 07:39
Show Gist options
  • Select an option

  • Save ryo1kato/a36190e9ce25ab89067a to your computer and use it in GitHub Desktop.

Select an option

Save ryo1kato/a36190e9ce25ab89067a to your computer and use it in GitHub Desktop.
cat result | while read t p; do t1=${t%-*}; t2=${t#*-}; p1=${p%-*}; p2=${t#*-}; t+=(t1 $t2); if (( p1 > p2 )); then echo ${t1} win; echo ${t2} lose; else echo ${t2} win; echo ${t1} lose; fi; done | sort | uniq -c
@ryo1kato
Copy link
Author

ryo1kato commented Aug 2, 2014

$ cat calc.bash 
#!/bin/bash
while read t p
do  t1=${t%-*}
    t2=${t#*-}
    p1=${p%-*}
    p2=${t#*-}
    #t+=(t1 $t2)
    if (( p1 > p2 ))
    then echo ${t1} win
         echo ${t2} lose
    else echo ${t2} win
         echo  ${t1} lose
    fi
done | sort | uniq -c
                                                                                
$ ./calc.bash < result 
      2 A lose
      1 A win
      2 B lose
      2 B win
      1 C lose
      2 C win


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment