Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Unix awk command

Options
  • 01-04-2012 10:05pm
    #1
    Registered Users Posts: 839 ✭✭✭


    Hi,
    Looking for some help on an awk command to merge two file together, would really appreciate seom guidance. I have 2 files like this....

    file1.txt

    1 a
    2 b
    3 c
    4 d
    5 e
    6 f
    7 g
    8 h
    9 i

    file2.txt

    1 j
    3 k
    5 l
    7 m
    9 n

    I'd like to merge the two files together - listing all the values from both columns of file1 as well as the values from the 2nd column of file2 where the first column matches file1 - so you end up with this.....

    output...

    1 a j
    2 b
    3 c k
    4 d
    5 e l
    6 f
    7 g m
    8 h
    9 i n

    Any idea on quick awk command to do this?

    thanks in advance


Comments

Advertisement