${#string} |
Length of $string |
${string:position} |
In $string, start extracting substrings from position $position |
${string:position:length} |
In $string, a substring of length $length is extracted starting from position $position |
${string#substring} |
Delete the substring of the shortest match $substring from the beginning of the variable $string |
${string##substring} |
Delete the substring of the longest matching $substring from the beginning of the variable $string |
${string%substring} |
Delete the substring of the shortest match $substring from the end of the variable $string |
${string%%substring} |
Delete the substring of the longest matching $substring from the end of the variable $string |
${string/substring/replacement} |
Use $replacement to replace the first matching $substring |
${string//substring/replacement} |
Use $replacement instead of all matching $substring |
${string/#substring/replacement} |
If the $string prefix matches the $substring, then the $replacement is used instead of the matching $substring |
${string/%substring/replacement} |
If the $string suffix matches the $substring, then the $replacement is used instead of the matching $substring |
expr match "$string" ‘$substring‘ |
Matches the length of the $substring* at the beginning of the $string |
expr "$string" : ‘$substring‘ |
Matches the length of the $substring* at the beginning of the $string |
expr index "$string" $substring |
The position in $string where the first character of the $substring is matched to |
expr substr $string $position $length |
Extracting substrings of length $length from position $position in $string |
expr match "$string" ‘\($substring\)‘ |
Extract the $substring* from the $string's opening position |
expr "$string" : ‘\($substring\)‘ |
Extract the $substring* from the $string's opening position |
expr match "$string" ‘.*\($substring\)‘ |
Extract $substring* from the end of $string |
expr "$string" : ‘.*\($substring\)‘ |
Extract $substring* from the end of $string |