Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
valid=0
while read line
do
first_pos=$(echo $line | cut -d ' ' -f 1 | cut -d '-' -f 1)
second_pos=$(echo $line | cut -d ' ' -f 1 | cut -d '-' -f 2)
char=$(echo $line | cut -d ' ' -f 2 | sed 's/://')
pass=$(echo $line | cut -d ' ' -f 3)
first_char=`echo $pass | cut -c $first_pos`
second_char=`echo $pass | cut -c $second_pos`
if [[ ($first_char == $char || $second_char == $char) && !($first_char == $char && $second_char == $char) ]]
then
valid=$(($valid + 1))
fi
done <<< $(< $1)
echo $valid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment