Skip to content

Instantly share code, notes, and snippets.

@jonpchin
Created May 29, 2017 21:20
Show Gist options
  • Select an option

  • Save jonpchin/8002fc482278bcecc0872e1a7d83ff10 to your computer and use it in GitHub Desktop.

Select an option

Save jonpchin/8002fc482278bcecc0872e1a7d83ff10 to your computer and use it in GitHub Desktop.
Count Duplicates count_duplicate.sh "abcdeaB" => 2
#!/bin/bash
#Count Duplicates count_duplicate.sh "abcdeaB" => 2
total=0
for letter in {a..z} ; do
storage=$(echo "$1" | grep -o -i "$letter" | wc -l)
if [ $storage -gt 1 ]
then
total=$((total+1))
fi
done
echo $total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment