Search This Blog

Bash: replace substring using regular expressions

With bash, you can replace string using ${variable//pattern/replacement}
a="<token>XXX</token>"

# to replace the token element value with YYY
a=${a//<token>[a-zA-Z0-9]*<\/token>/<token>[a-zA-Z0-9]*<\/token>}



see also

No comments:

Post a Comment