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}"
More Related Contents:
- How to wait in bash for several subprocesses to finish, and return exit code !=0 when any subprocess ends with code !=0?
- Can I export a variable to the environment from a Bash script without sourcing it?
- Passing arguments to an interactive program non-interactively
- How to urlencode data for curl command?
- What’s the difference between [ and [[ in Bash? [duplicate]
- How to execute a bash command stored as a string with quotes and asterisk [duplicate]
- How to define hash tables in Bash?
- Why isn’t tilde (~) expanding inside double quotes? [duplicate]
- What is the difference between “$@” and “$*” in Bash? [duplicate]
- Count occurrences of a char in a string using Bash
- Shell: How to call one shell script from another shell script?
- How to redirect output of an entire shell script within the script itself?
- How to represent multiple conditions in a shell if statement?
- How to split one string into multiple strings separated by at least one space in bash shell?
- How to make .bashrc aliases available within a vim shell command? (:!…)
- What is the exact meaning of IFS=$’\n’?
- How to escape history expansion exclamation mark ! inside a double quoted string?
- How to check if running in Cygwin, Mac or Linux?
- Using getopts inside a Bash function
- How to create a bash script to check the SSH connection?
- choosing between $0 and BASH_SOURCE
- What does ${ARGUMENT+x} mean in Bash? [duplicate]
- Use sed to replace all backslashes with forward slashes
- Variables as commands in Bash scripts
- How can I calculate time elapsed in a Bash script?
- sed multiline delete with pattern
- How to give a pattern for new line in grep?
- What’s the cmd/PowerShell equivalent of back tick on Bash?
- In Bash test if associative array is declared
- How to read variables from file, with multiple variables per line?