Command line tips & tricks - concatenation with cat

Filed under
HowTos

If you’ve done any sort of command line stuff on a Unix-like OS, you’ve probably come across cat. It stands for ‘concatenate’, but most often we use it to simply spit out the contents of a file, like this:

$ cat myfile

So hang on - why is it called concatenate if we’re only showing the contents of one file? Well, if you give cat one file, it just does that.

As the name suggests however, you can give cat two files and it will - guess what - concatenate them together and throw them out at the end.

Like this:

$ cat fileone filetwo

There, you’ll be given an output containing the contents of both files. Why is this useful? It might not seem it, but there are a number of situations where this could help you.

Full Story.