5 simple ways to get the length of a string from Shell

5 simple ways to get the length of a string from Shell

strLen() {
	echo "${#1}"
}

strLen() {
	echo "${1}"| wc -L
}

strLen() {
	echo -n "${1}"| wc -c
}

strLen() {
	echo "${1}"| awk '{print length($0)}'
}

strLen() {
	echo `expr length ${1}`
}

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example