How to reference captures in bash regex replacement -


how can include regex match in replacement expression in bash?

non-working example:

#!/bin/bash name=joshua echo ${name//[oa]/x\1} 

i expect output jxoshuxa \1 being replaced matched character.

this doesn't work though , outputs jx1shux1 instead.

bash> name=joshua   bash> echo $name | sed 's/\([oa]\)/x\1/g'   jxoshuxa 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -