The cat command (short for catenate) is primarily used to display the entire contents of a file on your terminal screen.
Think of echo as a way to print what you type, while cat is a way to "read" what is already written inside a file.
Examples of what cat can do:
-
Read a file: If you have a file named
note.txt, you would type:cat note.txtThe terminal will then show you everything written inside that file.
-
Display system info: You can use it to look at system files. Try this in your terminal right now:
cat /etc/os-releaseThis will display information about the Linux operating system you are currently using in LabEx.
-
Combine files: It can also "link" multiple files together and show them all at once:
cat file1.txt file2.txt
In short: If you want to see what is inside a file without opening a text editor, cat is the quickest way to do it!
For your current lab step, we are using echo because we are creating fresh output. Once you've typed echo "Hello LabEx", feel free to click Continue!