-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2000
Christopher Slycord edited this page May 6, 2020
·
4 revisions
${#variable}
will be equal to the number of characters in "${variable}"
This is the same result as "$( echo "$variable" | wc -m )"
When "$variable" only contains single-byte characters, it's also the same as "$( echo "$variable" | wc -c )"
#!/usr/bin/env bash
if [ "$( echo "$1" | wc -c )" -gt 1 ]; then
echo "greater than 1"
fi
if [ "$( echo "$1" | wc -m )" -gt 1 ]; then
echo "greater than 1"
fi