[ Bjarni R. Einarsson / blog: IS EN ]


Shell magic: the join command

2007-01-16 16:10

The other day one of my coworkers pointed out a Unix text manipulation command that I hadn't known existed.

It's named "join". It does more or less the same thing as select/joins do in the SQL world, it merges together lines from two text files into a single stream, based on a keyword found in each line.

So joining on the first column:

bre Bjarni
are Andri
mar Már
gaur Gaurinn

with

bre Ireland
bre Iceland
are Iceland
mar Iceland

will output

bre Bjarni Ireland
bre Bjarni Iceland
are Andri Iceland
mar Már Iceland

Isn't that just great? Join is my new favorite Unix command!

Another interesting command revealed to me at the same time was "comm", but I don't think it's nearly as cool.

   
Name:
Subject:

Note: If all you want to do is correct grammar or spelling, please send me e-mail instead of cluttering up the diary. Thank you!

Yes! I will write my own HTML!    

Valid HTML: <P>, <BR>, <A HREF="...">...</A>, <UL>, <OL>, <LI>, <I>, <B>
Blockquote and image tags don't work!

Please leave these blank:

Nýtt í dagbókinni