String Length
In this page:
String Length
${#variable} gives the number of characters in a string variable. It's a fast, built-in way to check string length without calling an external command like wc. This syntax is part of Bash's parameter expansion feature.
Note: Use ${#var} instead of piping through wc -c — it avoids starting a subprocess.
Example: String Length
#!/bin/bash
name="Hello, Bash!"
echo "Length: ${#name}"
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 11 topics to unlock
0/11 topics done
Complete these topics first: