Exercism/bash/pangram/pangram.sh
2023-04-28 18:25:06 +02:00

18 lines
544 B
Bash

#!/usr/bin/env bash
# Convert to lowercase and remove non-alphabetic characters
sentence_alpha="$(echo "$1" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alpha:]')"
# `fold -w1` splits the string into individual characters, one per line
# `sort -u` remove duplicates
# `tr` delete newline characters
sentence_unique="$(echo -n "${sentence_alpha}" | fold -w1 | sort -u | tr -d '\n')"
# Check if the unique alphabets count is 26 (total number of English alphabets)
if [[ ${#sentence_unique} == 26 ]]; then
echo "true"
else
echo "false"
fi