Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Unix awk command

  • 01-04-2012 09:05PM
    #1
    Registered Users, Registered Users 2 Posts: 867 ✭✭✭


    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