An ad-free and cookie-free website.
Learn to join lines from two files at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux paste Command Summary with Examples (4:09)
Our thirty-eighth word, or command to memorize is
join from our category
join allows you to join lines from
||Treat first line as a header|
||Join on FIELD in the first file|
||Join on FIELD in the second file|
Recall from the previous five videos, we made a delimited file, like
one you might analyze in a spreadsheet. Now we'll
join it with another file.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
join command has
13 options, and the arguments are the two files you'd
like to join.
Like most commands, help is available with double-dash
--help. And the
--header option is for files with
headers. Here we'll be connecting two files on a field common using
these two options here (
-1 FIELD and
So why is
join an important command?
Well, if you have structured tabular data, like you might in the
scientific fields, then you'll need to connect files.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Let's first take a look at the two files we're connecting,
the first created in the last video,
video38a.txt, shows dates, video
text files and number of views one year from now, found using a
crystal ball ;).
Some are popular, and some are not.
Next, I've also created another text file,
video38b.txt listing the content
creator for each of the 13 videos. Myself or Jennifer.
Next, let's see who's better,
table 1 field 2, and table 2 on field 1,
-t ":", where we put in the delimiter
here with a colon, then the files, and what we'll do is
write that to
Okay good, and last, let's get a drumroll here and
cat those results.
Look at this. Video (row) 1, 6 views for Paul. Video (row) 2, 8 views for Paul.
Video (row) 3, 819 thousand views for Jennifer. Hmmm. Oh wow.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
join has a handy option,
-e that will input a default, like
NA, when data is missing.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you haven't been able to tell, here we like our comedy dry like the desert. It may come across better on video, subscribe here.
pastecommand, hit Back.
grepcommand, click Next.
A newly-updated free resource. Connect and refer a friend today.