Skip to content

Instantly share code, notes, and snippets.

@turing4ever
Created February 5, 2018 23:24
Show Gist options
  • Save turing4ever/eccacc2b65aed1857dd13e53b7310c8b to your computer and use it in GitHub Desktop.
Save turing4ever/eccacc2b65aed1857dd13e53b7310c8b to your computer and use it in GitHub Desktop.
How to figure out the length of a string in bash?
# How to figure out the length of a strign in bash?
#expr length
expr length "string" #This works on Ubuntu, but not on Mac
#wc -c
echo -n "string" | wc -c # -n not to output trailing newline in echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment