An ad-free and cookie-free website.
Learn to select sections of text at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux cut Command Summary with Examples (3:51)
Our thirty-third word, or command to memorize is
cut from our category
cut allows you to select sections from
lines of text.
||Select using bytes specified|
||Select using characters specified|
||Select using fields specified|
Recall from the previous videos, we've been adding skills to help
filter potentially huge files and
is another tool for our arsenal.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
cut command has
10 options, and the argument is our file.
Like most commands, help is available with double-dash
--help. The command has options for
cutting bytes using
-c, and we'll use that one here.
-f for fields.
A delimiter option is available too. If you've worked with spreadsheets then this concept is familiar.
So why is
cut an important command?
Well, we're often given data sets in columnar structure and, like in a
spreadsheet, we need a way to pull out what is useful.
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. I started with an
command, for a list of files we've created up to this point, naming it
video33.txt if you'd like to do the
same on your end. And we can
cat this to view.
Next, let's cut a couple columns we're interested in, by using
cut -c 19-24, 32-42 and the argument
And last, because we'd like to add a delimiter between the fields,
let's add the option
--output-delimiter=":". Then we're
good to go. And write that whole thing to a new file
video34.txt, because we're not
done with this data.
cat it if you'd like.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
So we've all seen a
cut command on a
PC or a Mac, have you noticed how flexible this one is?
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:
Keep the learning train moving forward. Connect at YouTube, Twitter and at our no-spam email list to stay on track.
uniqcommand, hit Back.
diffcommand, click Next.
A newly-updated free resource. Connect and refer a friend today.