All Linux administrators know this tool and some make use of it very often:
cat. Also Linux beginners get to know this quickly and use it a lot. Most people love it so much that they utilize it in every situation whether it's needed or absolute nonsense. Not very seldom this results in strange constructs like:
cat file | grep string
or my favorite one to copy a text file
cat file1 > file2
All these operations cost you a new process whereas you could just do the same much cheaper with redirection operators (and the second one of course with
cp). As a rule of thumb one can say that
cat in front of a pipe is useless. Our first example could also be done with
<file grep string grep string < file
or in this special case even better with
grep string file
grep is also built to work with files, not only with STDIN.
cat stands for (con)catenate and therefore it's been invented to concatenate two or more files to one single file. E.g.
cat file1 file2 > catfile
In nearly all cases where you use
cat on just one file you could do it a better way with redirection operators. One of the few exceptions of this rule is a construct like this:
(command1 ; cat file ; command2) > outputfile
where you redirect the collected output of a subshell to a file (or pipe it to another command). And of course another one is the case of printing file contents to the screen but wouldn't you use
lv for that? Especially on long files
cat does a pretty bad job here.
So keep this in mind and try to lower your use of
cat if you are one of those using it all the time. Otherwise one day you could find yourself nominated for the Useless Use of Cat Award (UUOC).
Read more about cat: