Intro To 'cat' Command In Linux
2023-04-28 - By Robert Elder
I use the 'cat' command to read the contents of multiple files at once:
cat file1.txt file2.txt file3.txt
I can type one or more file names after the cat command, and the contents of these files will be printed one after another on the terminal. For example, let's first create two files that contain lists of names. In the file 'names1.txt', we'll put:
Branden McKenna
Verity Jayda
Christopher Rene
Justy Kaiden
and in the file 'names2.txt' we'll put:
Triston Issy
Ralphie Birdie
Alec Jacqueline
I can use the cat command to print out each file individually, or I can use it to print out both files together:
cat names1.txt
Outputs:
Branden McKenna
Verity Jayda
Christopher Rene
Justy Kaiden
cat names2.txt
Outputs:
Triston Issy
Ralphie Birdie
Alec Jacqueline
cat names1.txt names2.txt
Outputs:
Branden McKenna
Verity Jayda
Christopher Rene
Justy Kaiden
Triston Issy
Ralphie Birdie
Alec Jacqueline
I can also use the 'cat' command to print out all of the lines in both files and pipe them into the sort command to have them sorted alphabetically:
cat names1.txt names2.txt | sort
Outputs:
Alec Jacqueline
Branden McKenna
Christopher Rene
Justy Kaiden
Ralphie Birdie
Triston Issy
Verity Jayda
And that's why the 'cat' command is my favorite Linux command.
Intro To 'stty' Command In Linux
Published 2023-10-04 |
$1.00 CAD |
Intro To 'nproc' Command In Linux
Published 2023-07-15 |
Intro To 'comm' Command In Linux
Published 2023-09-06 |
How To Force The 'true' Command To Return 'false'
Published 2023-07-09 |
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21 |
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01 |
Intro To 'chroot' Command In Linux
Published 2023-06-23 |
Join My Mailing List Privacy Policy |
Why Bother Subscribing?
|