In this article we will provide you bash script code to reverse an array. In this function you can provide an array or multiple arguments.
Code Example –
#!/bin/bash
reverse_array() {
    shopt -s extdebug
    f()(echo "${BASH_ARGV[@]}"); f "$@"
    shopt -u extdebug
}
arr=("Animals" "are" "like" "humans")
reverse_array "${arr[@]}"
# Output:
# humans like are Animals