Skip to content

Instantly share code, notes, and snippets.

@mattk42
Created December 3, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattk42/92a73eec81114cfdacd24c654fb8c6d9 to your computer and use it in GitHub Desktop.
Save mattk42/92a73eec81114cfdacd24c654fb8c6d9 to your computer and use it in GitHub Desktop.
#!/bin/bash
valid=0
while read line
do
min=$(echo $line | cut -d ' ' -f 1 | cut -d '-' -f 1)
max=$(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)
count=$(echo $pass | grep -o $char | wc -l)
if [ $count -ge $min -a $count -le $max ]
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