An ad-free and cookie-free website.
Learn to combine lines from two text files at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux paste Command Summary with Examples (3:41)
Our thirty-seventh word, or command to memorize is
paste from our category
paste allows you to combine lines
from two files.
||Print help screen|
||Use characters from LIST as delimiters|
Recall from video 33, we learned how to
cut and now we'll learn how to
paste, or more literally add columns
from one file to another.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
paste command has
4 options, and the arguments include the
first file, and the second is what you'd like to add to the first.
Like most commands, help is available with double-dash
--help. The option we'll use here is
-d because we're using the colon
symbol as a delimiter.
So why is
paste an important command?
Well, for data often stored in spreadsheets or databases,
paste offers a way to add fields from
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 file we created in the last
video using a
cat -n, which numbers
lines, and it's
We have 13 rows, the dates videos were created in this column (middle) and the video text file (third column).
Next, I've created another text file in
video37.txt listing the number of
YouTube views for each video one year from now, found using my
crystal ball, of course ;). Let's look at it with
It's thirteen rows, but it isn't useful sitting in a separate file,
is it? So let's
Okay, go optionless with
And we'll see here that the output really isn't ideal.
And last, let's add the
:, like this, as the
delimiter between fields.
This gives us better results.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
paste is a handy way of cleaning
up tabular data. Hang on tight to see what we do with it next.
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:
It really helps to pair this web content with the videos. Subscribe to our YouTube Channel and follow @factorpad on Twitter to receive updates.
sdiffcommand, hit Back.
join, click Next.
A newly-updated free resource. Connect and refer a friend today.