Counting Characters in a Bash String - Quick Tip @WorldOfZeroDevelopment
Counting Characters in a Bash String - Quick Tip  @WorldOfZeroDevelopment
Uploaded January 2020 | Updated November 2026, 2 days ago
Bash has a series of Shell Parameter Expansion features that allow you to do a number of different things when working with your shell. One of those features makes it possible to get the number of characters in a string easily.

For example this stores "Hello World" into `myvariable` and then writes `11` to the screen (the number of characters in the string).

```bash
myvariable="Hello World"
echo "${#myvariable}"
```

You can read more about Bash's features and Shell Parameter Expansion specifically in the Bash docs: gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Shell-Parameter-Expansion

Join the World of Zero Discord Server: discord.gg/hU5Kq2u
Counting Characters in a Bash String - Quick TipA Pixelated Shader - Circular Pixel Shader - Part 1Search Your Workspace in Visual Studio Code - Quick TipExploring a Trochoidal Wave ShaderCreating Custom GitHub Issue TemplatesLive Code Reloading with `dotnet watch` - Quick TipImplementing C# Extension MethodsSupporting Grid Rendering - LINQ for Unity - Part 3Lets Make a Lazy String Parser in C#I Learn Blazor - C# in Your Web BrowserTurning OpenSCAD Files into STL Meshes with GitHub ActionsLive Coding a Basic 6 Degree of Freedom Flight Controller
World of Zero |

Counting Characters in a Bash String - Quick Tip

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER