Tuesday, July 8, 2008

Shell:Bash:replace substring in string

${string/substring/replacement} Replace first match of $substring with $replacement
${string//substring/replacement} Replace all matches of $substring with $replacement
${string/#substring/replacement} If $substring matches front end of $string, substitute $replacement for $substring
${string/%substring/replacement} If $substring matches back end of $string, substitute $replacement for $substring


Refer to the link for more information.

No comments:

Locations of visitors to this page