Last active
December 3, 2021 21:06
-
-
Save vhata/da8144716c1a054f11f5830f02058a1d to your computer and use it in GitHub Desktop.
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
#!/opt/homebrew/bin/bash | |
INPFILE=day3.txt | |
cp $INPFILE oday3s1.txt | |
cp $INPFILE cday3s1.txt | |
echo -n '^' > opatfile | |
echo -n '^' > cpatfile | |
len="$(($(head -n1 $INPFILE | wc -c) - 1))" | |
for z in $(seq 1 $len) ; do | |
owanted=$(cat oday3s${z}.txt | cut -c${z} | sort | uniq -c | sort -n | tail -n1 | awk '{print $2}') | |
cwanted=$(cat cday3s${z}.txt | cut -c${z} | sort | uniq -c | sort -rn | tail -n1 | awk '{print $2}') | |
echo -n "$owanted" >> opatfile | |
echo -n "$cwanted" >> cpatfile | |
egrep -f opatfile oday3s${z}.txt > oday3s$(($z + 1)).txt | |
egrep -f cpatfile cday3s${z}.txt > cday3s$(($z + 1)).txt | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment