Skip to content

Try our new Crash Courses!

Become a member using the button below to hide this banner and gain access to our new Crash Courses.

View file contents – Terminal

Summary

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.

Details

Options

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

cat -n my-file

Exercises

Try the following commands in your project folder:

cat index.html
less index.html

References

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

Back to: Terminal Reference > Terminal Basic Commands