The cat command in Linux is primarily used for the following functionalities:
-
Display File Contents: It can read and display the contents of a file in the terminal. For example:
cat filename.txt -
Concatenate Files: It can combine multiple files into one. For example:
cat file1.txt file2.txt > combined.txt -
Create New Files: You can create a new file and write content to it using
cat. For example:cat > newfile.txt(Type your content and then press
CTRL+Dto save.) -
Append to Files: It can append content to an existing file. For example:
cat >> existingfile.txt(Type your content and then press
CTRL+Dto save.) -
Display Line Numbers: You can display line numbers along with the content using the
-noption:cat -n filename.txt
These functionalities make cat a versatile tool for file manipulation in the command line.
