In this tutorial, you will understand the differences between the linux commands like cat, zcat, lolcat and tac
- how to use cat command in linux
- how to use tac command in linux
- how to use zcat command in linux
- how to use lolcat command in linux.
1. cat command
- Cat is one of the most widely popular command in linux terminal
- It is used to perform the file operations like file creation, display, text appending, files merging, etc
Usages
- File Creation and Display
- Text Appending to File
- Files Merging
- Displaying File Contents with Line Numbers
Syntax
cat filename
Where,
filename is an existing input file name.
Example
2. zcat command
- Zcat stands for compressed cat
- This command is used to display the contents of an already compressed text file (.gz).
Syntax
zcat filename.gz
Where,
filename is an existing input compressed file name.
Example
3. lolcat command
- It is the latest linux command for linux, BSD and OSX
- Unlike cat command, this command is used to display the file contents with rainbow colours in the terminal
- Unlike cat command, this command is used to show the animation of a text message using the special options -a -d seconds (ex. Lolcat -a -d 500)
- Like cat command, it performs the file operations like file creation, display, text appending, files merging, etc
Usages
- Showing animated text in terminal
- File Creation and Display
- Text Appending to File
- Files Merging
- Displaying File Contents with Line Numbers
NOTE
- By default, this command is NOT installed on your machine. So you need to externally install this command based on your linux distribution, before using it.
Syntax
lolcat filename
Where,
filename is an existing input file name.
Example
4. tac command
- It is the reverse model of cat command.
- It is also called as cat backward
- This command is used to display the file contents in reverse order (bottom to top)
Usages
- It is for files concatenation and print file contents in reverse order
Syntax
tac filename
Where,
filename is an existing input file name.
Example