How To Use cat Command In Linux / UNIX
The cat command in Linux/UNIX is used to concatenate and display files, as well as to create and edit files. Here are some basic examples of how to use the cat command:
- Display the contents of a file:
cat command followed by the file name. For example:cat filename.txtThis will display the contents of the file "filename.txt" in the terminal.
- Display the contents of multiple files:
cat command followed by the file names, separated by spaces. For example:cat file1.txt file2.txt file3.txtThis will display the contents of all three files in the terminal.
- Concatenate files:
cat command followed by the input file names, and redirect the output to a new file using the ">" operator. For example:cat file1.txt file2.txt > combined.txtThis will concatenate the contents of "file1.txt" and "file2.txt" and save the result in a new file called "combined.txt".
- Create a new file:
cat command followed by the ">" operator and the name of the new file. For example:cat > newfile.txtThis will create a new file called "newfile.txt" and allow you to enter text into it. To save the file, press Ctrl + D.
By using the cat command, you can view, concatenate, and create files in Linux/UNIX.
