bash: array - Start an array from an alternative position.



  • Take into account the main readme for this section. README first.

    An array called planet.

    $ declare -a planet=(earth wind fire)
    

    Start the array planet from from position zero and print two elements.

    $ echo "${planet[@]:0:2}"
    earth wind
    

    Start from position 1 and no entry for the number of elements; prints the rest of the elements.

    $ echo "${planet[@]:1}"
    wind fire
    

Log in to reply
 

© Lightnetics 2024