end of day 5 week 1
This commit is contained in:
19
week 1/day 5/exo2.sh
Executable file
19
week 1/day 5/exo2.sh
Executable 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"
|
||||
Reference in New Issue
Block a user