fork download
  1. #!/bin/bash
  2.  
  3. comp="LP"
  4. n_names="abc456.com,def123.com,w xy098.com"
  5. IFS=',' read -r -a n_split_list <<< "$n_names"
  6.  
  7. IFS=, read -ra "$comp"_list < <(printf '%s,' "${n_split_list[@]}")
  8. export ${comp}_list
  9.  
  10. # check content of new array
  11. declare -p ${comp}_list
  12.  
Success #stdin #stdout 0.01s 5536KB
stdin
Standard input is empty
stdout
declare -ax LP_list=([0]="abc456.com" [1]="def123.com" [2]="w xy098.com")