Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Teachable.

View file contents – Terminal


To print out the contents of a file all at once inside your terminal, use the cat command:

cat my-file

To print out the contents of the file in a scrollable format using your terminal, use the less command:

less my-file

You can use the Up and Down arrow keys to scroll through the contents using less. To close the file, press the Q key.



You can use the -n flag with the cat command to print out line numbers for each line.

cat -n my-file


Try the following commands in your project folder:

cat index.html
less index.html


Command Line Primer on the Apple Developer Archive (see the section called Frequently Used Commands)

Back to: Terminal Reference > Terminal Basic Commands