Files
7-Modern-Languages-in-7-Wee…/week 1/day 5/exo2.sh
2026-01-22 21:36:02 +01:00

19 lines
297 B
Bash
Executable File

#!/bin/bash
read -p "please enter a phrase: " text
if [[ -z "$text" ]]; then
echo "please enter a string"
exit
fi
count=0
for ((i=0; i<${#text}; i++)); do
char="${text:i:1}"
if [[ "$char" =~ [A-Za-z]]]; then
count++
fi
done
echo "Your string contain $count letter"