end of day 5 week 1

This commit is contained in:
2026-01-22 21:36:02 +01:00
parent 82b79336ea
commit 3e23329086
8 changed files with 529 additions and 0 deletions

19
week 1/day 5/exo2.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/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"