Created
May 29, 2017 21:20
-
-
Save jonpchin/8002fc482278bcecc0872e1a7d83ff10 to your computer and use it in GitHub Desktop.
Count Duplicates count_duplicate.sh "abcdeaB" => 2
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 | |
| #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