The cat
command is a utility in Linux and Unix systems that allows you to concatenate and display files. It is commonly used to view the contents of a file or to create a new file by combining multiple files.
Here are some examples of how you can use the cat
command:
cat file.txt
This command will display the contents of the file file.txt
.
cat file1.txt file2.txt file3.txt > combined.txt
This command will create a new file called combined.txt
by concatenating the contents of file1.txt
, file2.txt
, and file3.txt
.
cat file1.txt file2.txt file3.txt
This command will display the contents of file1.txt
, file2.txt
, and file3.txt
one after the other.
cat -n file.txt
This command will display the contents of file.txt
with line numbers.
cat -s file.txt | less
This command will display the contents of file.txt
and pause after each screenful of output. You can use the Space
key to display the next screenful of output and the q
key to exit.
cat -E file.txt
This command will display the contents of file.txt
and highlight the ends of lines with a $
symbol.
There are many other options and arguments that you can use with the cat
command. For a complete list of options and more detailed information about how to use the cat
command, you can consult the cat
man page by running the man cat
command.