That's a great follow-up! As the name concatenate implies, cat is designed to handle multiple files by reading them one after another in a single continuous stream.
Here is how it works:
1. Displaying multiple files
If you provide more than one filename to the cat command, it will display the contents of all those files in the order you listed them.
For example, if you create a second file:
echo "Learning is fun!" > second.txt
Then run cat with both files:
cat hello.txt second.txt
Output:
Hello, Linux
Learning is fun!
2. Combining (Concatenating) multiple files
One of the most powerful uses of cat is merging multiple files into a single new file using the redirection operator (>):
cat hello.txt second.txt > combined.txt
This command takes the content of hello.txt, adds the content of second.txt right after it, and saves the whole thing into a new file called combined.txt.
Summary
When cat handles multiple files, it:
- Reads them from left to right.
- Outputs them as one long stream of text.
- Does not add any extra spaces or markers between the files (it just sticks the end of the first to the start of the second).
Does that help clarify how cat gets its name? Feel free to try it out in your terminal!