Comments on 10 Linux cat Command Examples for Beginners
If you a regular Linux command line user, I am sure you must have used the cat command. The tool is mostly used for displaying contents of a file, although it provides many other small but useful features. In this article, we will discuss the cat command in detail, explaining some of its key features.
1 Comment(s)
Comments
Some useful options above.
99.9999% of the time when I see someone using 'cat', it isn't necessary. Pretty much every command that cat is used to create a stdin stream would be faster, less resources used, if the next command just read the file directly. Books and online examples commonly show
$ cat file | grep something
This is wasteful. grep knows how to read a file directly. grep knows how to read multiple files using globbing directly too.
Also, using 'cat' to display a file is usually not as useful as using more/less instead.
Of course, there are times when cat **is** useful and desired. I run into those about once a year.