Accept a string from terminal and echo suitable message if it does not have at least 10 characters

SOLUTION....

#!/bin/bash
# Script to check if entered string has at least 10 characters

echo "Enter a string:"
read str

length=${#str}   # count length of string

if [ $length -lt 10 ]; then
    echo "❌ The string is too short. It has only $length characters."
else
    echo "✅ The string is valid. It has $length characters."
fi

OUTPUT

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.