bash: Create a bash array without mapfile, declare or read.



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

    Declare variable as an array.

    $ IFS=$'\n' my_array8=( $(cat /etc/hosts) )
    

    Using the array. Access an element of the array.

    $ for line in "${my_array8[2]}"; do echo $line; done
    

Log in to reply
 

© Lightnetics 2024