Displaying the Contents of a File with cat and less

cat

To view the contents of a text file named testfile on your screen, assuming that you are the user hadi, use this command:

Text inside testfile is displayed on the screen but you cannot edit or work with the text. This command allow you to know the contents of a file but don’t want to make any changes.

less

When need to view the contents of a longer text file from the command line, you can use less. This produces a paged output, meaning that output stops each time your screen is full. You can then use your up and down arrow keys and page-up and page-down keys to scroll through the contents of the file.

Then, use q to quit and return to the command line:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s