Bourne shell - make a loop for each element in an array?

后端 未结 1 877
逝去的感伤
逝去的感伤 2021-01-26 09:36

This is my array:

ListTabs=\"\"
ListTabs=$ListTabs\"T_Tab1\\n\"
ListTabs=$ListTabs\"T_Tab2\\n\"
ListTabs=$ListTabs\"T_Tab3\"   
echo $ListTabs
arrArr=0
OLD_IFS=$         


        
相关标签:
1条回答
  • 2021-01-26 09:55
    listArr=( T_Tab{1,2,3} )
    sort -u "$FILESELECT_DAT" > "$SORT_OUT1"
    while read id; do
        for ListTabs in "${listArr[@]}"; do
         ...
        done
    done < "$SORT_OUT1"
    

    Take care that nothing in the body of the for-loop reads from standard input, or it will consume part of the input intended for the read command. To be safe, use a separate file descriptor:

    while read -u 3 id; do
    ...
    done 3< "$SORT_OUT1"
    
    0 讨论(0)
提交回复
热议问题