How can I write in nth column of a file in awk?

后端 未结 4 1956
醉梦人生
醉梦人生 2021-01-16 11:02

For example:

abc
xyz
123
546

input.txt:

asdad
asdad
adghf
dfytr

I wanted to add the above column in 2nd c

4条回答
  •  一整个雨季
    2021-01-16 11:37

    The command you're looking for is paste rather than awk. You could do it in awk but you'll probably find that paste is easier:

    pax> cat qq1
    asdad
    asdad
    adghf
    dfytr
    
    pax> cat qq2
    abc
    xyz
    123
    546
    
    pax> paste qq1 qq2
    asdad   abc
    asdad   xyz
    adghf   123
    dfytr   546
    

    Use paste -d' ' qq1 qq2 if you want a space rather than a tab for the delimiter.

提交回复
热议问题