O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Concatenating with cat

cat is one of the first commands which a command line warrior must learn. cat is a beautiful and simple command. It is usually used to read, display, or concatenate the contents of a file, but cat is capable of more than just that.

Getting ready

We scratch our heads when we need to combine standard input data as well as data from a file using a single-line command. The regular way of combining stdin data as well as file data is to redirect stdin to a file and then append two files. But we can use the cat command to do it easily in a single invocation.

How to do it...

The cat command is a very simple command that is used very frequently in daily life. cat stands for concatenate.

The general syntax of cat for reading a file's ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required