The cat
command is a very popular and versatile command in the 'nix ecosystem. There are 4 common usages of the cat
command. It can display a file, concatenate (combine) multiple files, echo text, and it can be used to create a new file.
The most common use of the cat command is to output the contents of a file. The following is an example that you can try.
echo "Dance, Dance" > cat_create #create a file
cat cat_create
In this simple example, we’re using a combination of echo
and a redirect to create a file containing “Dance, Dance”. We then use the cat
command to display the contents.
The output is as follows:
The output of the example commands
The previous example is actually a specific case of the cat command’s main function, which is to concatenate files for display. If we use the command the same way, but give it two or more files, then it outputs the concatenation for the files.
#linux