Can parameter expansion be nested in Bash? [duplicate]

No, you can’t. (You can in zsh, but not in bash, ksh or other shells.)

You need to use an intermediate variable:

foo=( 1 2 3 4 5 )
tmp=("${foo[@]/3/bar}")
echo "${tmp[@]:1}"

Leave a Comment