cat command in Linux / Unix with Examples

The cat command in Linux/Unix is a command-line utility that is used to concatenate and display the contents of one or more files. It stands for “concatenate.”

Some common uses of cat include:

  1. Displaying the contents of a file:
cat file.txt
  1. Concatenating the contents of multiple files into a single file:
cat file1.txt file2.txt > combined_file.txt
  1. Displaying the contents of multiple files:
cat file1.txt file2.txt
  1. Creating a new file and adding contents to it:
cat > new_file.txt
  1. Displaying the contents of a file, page by page:
cat file.txt | less
  1. Displaying the contents of a file in reverse order:
tac file.txt

These are just a few examples of the ways that the cat command can be used. It’s a simple but powerful tool that can be used in many different ways to manipulate and display the contents of files.

Leave a Comment