Concatenate an array with itself

Sort by

recency

|

143 Discussions

|

  • + 0 comments
    xargs yes 2>/dev/null | head -n 3 | tr $'\n' ' '
    

    Nifty trick

  • + 0 comments

    "Concatenating an array with itself creates a new array with the elements of the original array repeated twice in sequence." lotusbook247.com login

  • + 0 comments

    "Concatenating an array with itself creates a new array with the elements of the original array repeated twice in sequence." lotusbook247.com login

  • + 1 comment
    readarray -t countries
    
    multCountries=("${countries[@]}" "${countries[@]}" "${countries[@]}")
    echo ${multCountries[@]}
    
  • + 0 comments
    echo ${array[@]} ${array[@]} ${array[@]}
    

    or if you want to make it as 1 array

    array=(${array[@]} ${array[@]} ${array[@]})
    # Three times because it completly override array
    echo ${array[@]}