string manipulation API Reference
Bash parameter expansion — built-in string operations performed on shell variables without external tools.
string manipulation
Bash parameter expansion operators for measuring, slicing and replacing text in variables.
${#var}Returns the length of the variable's value in characters.
Returns: integer
${var:offset:length}Extracts a substring starting at offset (0-based) with the given length. Omit length for to-end.
Returns: string
${var/old/new}Replaces the first match of old (glob pattern) with new in var's value.
Returns: string
${var//old/new}Replaces all matches of old (glob pattern) with new in var's value.
Returns: string
${var#prefix}Removes the shortest match of prefix from the beginning of var's value.
Returns: string
${var%suffix}Removes the shortest match of suffix from the end of var's value.
Returns: string
${var^^}Returns the value of var converted to uppercase. Requires Bash 4.0+.
Returns: string
${var,,}Returns the value of var converted to lowercase. Requires Bash 4.0+.
Returns: string