echo "${x[@]:0:3}" # elements 0, 1, 2 of array x, individually quoted
echo "${x[@]:3:2}" # elements 3, 4 of array x, individually quoted
echo "${x[@]:m:n}" # n elements array x, starting at index m
echo "${x[1]}" # first element of array (in zsh)
("${x[0]}" # in bash)
# for portability, use e.g.
echo "${x[@]:0:1}" for first element of array
Pipe status
In bash, we use
echo "${PIPESTATUS[@]}"
for an array of exit statuses of processes in a pipe. For example
false | true | false | true | true
echo "${PIPESTATUS[@]}"
# outputs: 1 0 1 0 0
and in zsh we use the lowercase
echo "${pipestatus[@]}"
to do the same.