🎓 A1Learner
🔍
0 of 50 lessons completed

Shell Viewing Files

Viewing a file means printing its words on the screen. The cat command prints a whole file, start to finish.

Print a whole file

cat prints notes.txt in full, all four lines.

cat notes.txt

Print a table file

cat prints data.csv in full, header first.

cat data.csv

Print two files

cat prints notes.txt, then shopping.txt after it.

cat notes.txt shopping.txt

Print a file in a folder

Give cat a path, and it prints the file in that folder.

cat docs/readme.txt

Example

echo "Shopping list" > my-list.txt
cat my-list.txt
cat notes.txt

Key points

  • cat: a command that prints a whole file.
  • Use cat to read a short file in full.
  • Use cat with two file names to print one file after the other.
  • A long file scrolls past the top of the screen, so cat suits small files.

In this example, echo and > make a file with one line in it. Then cat prints that line. Next cat prints notes.txt in full, all four lines.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

Which command prints a whole file on the screen?