Search⌘ K
AI Features

Combining Files

Explore how to combine multiple files into one using the cat command, and learn to navigate large files efficiently with the more and less commands. Understand file concatenation, output redirection, and ways to read files page-by-page or search within them.

Reading multiple files

The cat command is the go-to tool for looking at the contents of small files. If we send multiple files to the cat command, it’ll read them all in the specified order. Let’s try it. We first create two files in our current directory:

$ echo "Hello" > hello.txt

$ echo "Goodbye" > goodbye.txt

Now, let’s use the cat command to read both files:

$ cat hello.txt goodbye.txt

Run the commands on the terminal below.

Terminal 1
Terminal
Loading...

As we can see, the output shows the content of both files. The cat command is actually designed to concatenate files. And as we’ve seen already, we can redirect standard output to a file using the > symbol.

Using the > operator

Let’s see this in action. Websites often have a common header and footer. Instead of repeating that content ...