What is the purpose of ${#STRING} in the script?

QuestionsQuestions8 SkillsProBasic String OperationsNov, 22 2025
063

In a bash script, ${#STRING} is used to get the length of the variable STRING. It returns the number of characters in the string stored in that variable.

For example:

STRING="Hello, World!"
echo "The length of the string is: ${#STRING}"

This will output:

The length of the string is: 13

0 Comments

no data
Be the first to share your comment!