The cat command is one of the most commonly used Linux commands. It is often used by experienced users while working with the terminal. With this command, you can very simply view the contents of a small file, merge several files, and more.
Despite the fact that the utility is very simple and solves only one problem in the best Unix style, it will be very useful. And to know about its additional features you just do not hurt. This article will look at the cat linux command, its syntax, options, and features.
The command name is an abbreviation from the word catenate. In fact, the task of the cat command is very simple - it reads data from a file or standard input and displays it on the screen. That's all the utility does. But with its options and output redirection operators, a lot can be done. First, consider the syntax of the utility:
You can specify several files to the utility and then their contents will be displayed one by one, without separators. Options allow you to modify the output very much and do exactly what you need. Consider the main options:
cat options file1 file2 ...
-b - number only non-empty strings;
-E - show $ at the end of each line;
-n - number all lines;
-s - delete empty duplicate lines;
-T - display tabs as ^I;
-h - display help;
-v - version of the utility.
The simplest and most obvious action where the cat linux command is used is to view the contents of a file, for example:
The ability to combine multiple files wouldn't be so useful if you couldn't write everything to a single file:
cat file1 file2 > file3 cat file3