Syntax

Bash String Length Syntax

In Bash, string length: gets the length of a string — ${#name}

Quick Answer

Syntax
${#name}
BashSyntax

String Length

Code example
${#name}

Gets the length of a string.

Learn More

How to string length in Bash

  1. Open your Bash file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Bash String Length Syntax

Use ${#name}.

Related Syntax References

Frequently asked questions

What is the Bash syntax for string length?

Use this pattern: ${#name}

Can I copy this Bash code example?

Yes. Use Copy code and adapt the example to your program.

Is this Bash syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify