Skip to content

Help us create more tutorials! Make a donation using the Donate button or become a member using the button below to hide this banner and track your progress.

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 Course > Terminal Basic Commands