The following example shows the functionality of strlen in a bash script.

[neo@techpulp ~]# echo $HOME
/home/neo
[neo@techpulp ~]# echo ${#HOME}
9
bash#

The following defines an utility function that can be used in a bash script.

#!/bin/bash

function strlen() { echo -n ${#1}; }

len=`strlen $HOME`

echo $len