An ad-free and cookie-free website.
Learn to send input to output at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux cat Command Summary with Examples (3:55)
Our tenth word, or command to memorize is
cat from the category Text.
cat allows you to send input to
output. In our last video we wanted to see available bash programs and
here the cat command will solve that by sending a file as output to
||Number the lines of output|
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s).
cat command has
12 options and arguments are inputs of two types:
files or text input to the keyboard.
I'll show you both, and in one example we'll use this option
-n to number the output lines.
A quick comment about input/ouput, there are three terms to remember all with default behavior here in our interactive shell. First, standard input is from the keyboard. Stantard output goes to the screen and standard error also goes to the screen.
So why is
cat an important command?
cat is the easiest way to send
text to the screen.
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, so
cat is similar to
less from video 5, except
less is more like a word processor.
cat instead just prints to the
screen. So let's use the file from video 5 and output it with line
Good. Now, try this, type
The shell is waiting for you to type something in standard input.
anything (and Enter).
Notice how it sits there, waiting for more?
If you are done, use
Ctrl-c to stop
And last, let's tackle that problem from the last video. Type
cat /etc/shells and look, it outputs
a file listing 5 shells to the screen.
Okay now you know how to use
And you know the syntax for commands, options and arguments.
One last tip about the
It's easy to write standard output to a file instead of the screen,
and I'll show you that next.
Okay, thanks for visiting today. I hope this was a fun introduction
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
Have questions? Subscribe and leave a note on YouTube. Follow @factorpad on Twitter for updates. Also, check out our no-spam email list.
bashcommand, hit Back.
typecommand, click Next.
A newly-updated free resource. Connect and refer a friend today.