Last active
March 22, 2019 15:46
-
-
Save mfurquimdev/6aee3df96a2bc4d4d2b7d209427b469e to your computer and use it in GitHub Desktop.
Script to calculate what time you can leave work on friday #Sextou
This file contains hidden or 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 | |
| if [ $# -ne 2 ]; then | |
| echo "usage: $0 <9 or 11> <CSV_FILE>" | |
| exit 1 | |
| fi | |
| iconv -c -f utf8 -t ISO-8859-1 "$2" > iso.csv | |
| # Calculating hours | |
| echo "45 60 * " > weekly.dc | |
| cut -d ';' -f $1 iso.csv | tail -n 5 | head -n 4 | sed -e's,:, 60 * ,g' -e's,$, +,g' >> weekly.dc | |
| echo "+++" >> weekly.dc | |
| echo "- 60 ~" >> weekly.dc | |
| cut -d ';' -f 7 iso.csv | tail -n 1 | sed -e's,:, 60 * ,g' -e's,$, +,g' >> weekly.dc | |
| echo "60 ~ sm sh sM sH Lm LM + 60 ~ sm Lh LH ++ sh Lm Lh n" >> weekly.dc | |
| tr -d '\n\r' < weekly.dc | dc | |
| echo -n "h" | |
| # Reverse the order to print minutes instead of hours | |
| sed -e's,n,r n,' weekly.dc | tr -d '\n\r' | dc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment