I have written a script that uses the below to display the amount of characters in "$var1"
echo -n "$var1" | wc -c
This displays the numeric value without an issue. However rather than display the value I wish to assign it to a the variable $char in order to then apply various conditions.
char=$(-n "$var1" | wc -c)
echo $char
However this produces the following error.
-n: command not found