You get a bonus - 1 coin for daily activity. Now you have 1 coin

bash/sh: Finding the Length of a Variable (String) in a Shell Script (bash or sh)

Practice



To find the length of a string variable, use this syntax:

{#variableName}

For example:

#!/usr/sh

a="TEST"

# Print the length of the variable $a (will output 4)
echo ${#a}

# Assign the length of the variable to another variable
varlen=${#a}

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "LINUX operating system"

Terms: LINUX operating system