0

I have two unl files:

#a.unl
310123
23371043
23370043
300054
700988
#twenty records like these

and

#b.unl
310123|name1|
311123|name2|
#almost a hundred records like these
23371043|namex|

i want to use awk so that I could join a.unl records with names from b.unl like this:

#c.unl
310123|namea|
23371043|nameb|
23370043|namec|
300054|named|
700988|namee|

Is it possible using awk? or do I have to use alternative like join?

Thank you very much for your help

1 Answer 1

1

Using awk:

awk -F'|' 'NR==FNR{a[$0];next}$1 in a' a.unl b.unl
Sign up to request clarification or add additional context in comments.

2 Comments

btw, is there a way to print the result into, say, c.unl?
@junda Redirect the output: awk -F'|' 'NR==FNR{a[$0];next}$1 in a' a.unl b.unl > c.unl

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.