lolcat Command in Linux (5 Examples)
- 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
Here you can find 5 examples of lolcat command in unix / linux terminal with examples. They are
- Creating a file
- Displaying contents of file
- Text Appending to File
- Merging Multiple Files into Single File
- Creating Text Animation
1. Creating a file
- Like cat command, this command can be used to create a file on linux or unix OS
- This is done with help of the output redirection operator >
Syntax
lolcat > filename
Example
2. Displaying contents of file
- Like cat command, this command can also used to display the contents of single file as well as multiple files
- This command is also used to show the file contents using the input redirection operator named <.
Syntax
lolcat filename // displaying contents of single file
lolcat file 1 file 2 … file n // displaying contents of multiple files at a time
Example – Showing file contents (without using < operator)
Example – Showing File Contents with using < input redirection operator
3. Text Appending to File
- Text message can be appended to file using lolcat command with append operator >>
- Here input must be an existing filename (old filename) else it will create a new file with input text.
Syntax
lolcat >> old-file
Example
4. Merging Multiple Files into Single File
- Using lolcat command, multiple files can be merged using the output redirection operator named >
- Here more than one input files have to be given for merging process
Syntax
lolcat file 1 file 2 … file n > res.txt
Example
5. Creating Text Animation
- This lolcat command can be used to create a text animation in the terminal
- This is done with help of special options -a and -d followed seconds, where -a indicates animation -d indicates the duration in seconds
Syntax
echo message | lolcat -a -d 200
Example
Differences between cat and lolcat command
S.N | cat | lolcat |
1. | It is a widely used popular command in linux / unix | It is a latest command in linux. |
2. | This command shows the file contents with line number using the special option -n | This command will not show the file contents with the line number. |
3. | This command will not show the output in rainbow colors | This command will display the file output in rainbow colors in terminal (by default) |
4. | This command can’t be used for creating text animation | This command can be used for creating the text animation. |