Python zip() behavior in bash?

前端 未结 4 1443
野的像风
野的像风 2021-02-12 14:56

Is there similar Python zip() functionailty in bash? To be specific, I\'m looking for the equivilent functionality in bash without using python:

$ echo \"A\" >         


        
4条回答
  •  时光取名叫无心
    2021-02-12 15:37

    You could do it in two steps with cat -n followed by join. (cat -n reproduces your file with line numbers at the start of each line. join joins the two files on the line numbers.)

    $ echo "A" > test_a
    $ echo "B" >> test_a
    $ echo "X" > test_b
    $ echo "Y" >> test_b
    $ cat -n test_a > test_a.numbered
    $ cat -n test_b > test_b.numbered
    $ join -o 1.2 -o 2.2 test_a.numbered test_b.numbered
    A X
    B Y
    

提交回复
热议问题