Looping over pairs of values in bash

前端 未结 7 2040
萌比男神i
萌比男神i 2020-11-22 03:19

I have 10 text files and I want to paste each file with its pair, such that I have 5 total files.

I tried the following:

for i in 4_1 5_         


        
相关标签:
7条回答
  • 2020-11-22 03:55

    Simplest so far:

    for i in "1 a" "2 b" "3 c"; do a=( $i ); echo ${a[1]}; echo ${a[0]}; done
    
    a
    1
    b
    2
    c
    3
    
    0 讨论(0)
提交回复
热议问题