How to extract a substring in Bash? May 27, 2022 Bash can extract a substring using the syntax ${VAR:START:LENGTH}. The START is the index of the first character, starting at 0. For example: $ string=abcd1234 $ echo "${string:4:3} 123