An Introduction to the Command-Line (on Unix-like systems)

by Oliver; 2014

12. echo and cat

More essential commands: echo prints the string passed to it as an argument, while cat prints the contents of files passed to it as arguments. For example:
$ echo joe 
$ echo "joe"
would both print joe, while:
$ cat file.txt
would print the contents of file.txt. Entering:
$ cat file.txt file2.txt
would print out the contents of both file.txt and file2.txt concatenated together, which is where this command gets its slightly confusing name.

Finally, a couple of nice flags for these commands:
$ echo -n "joe"            # suppress newline
$ echo -e "joe\tjoe\njoe"  # interpret special chars ( \t is tab, \n newline )
$ cat -n file.txt          # print file with line numbers

<PREV   NEXT>