How Do I Display the Contents of a Linux File?
You know how to get a list of files. But what if you want to take a peek at a file's contents? Several commands, including cat, more, and less, can be used to display files. Let's see how they work in this example: $ cat pig_info
Pigs make great pets, but they are not dogs or cats. Maybe
somewhere in between. I tend to believe that they have more
personality. They do require significant amounts of attention,
love, and scratches. But they aren't always snuggly in return.
The cat command (short for concatenate) shown in this example is like the DOS type command. In response to the command cat pig_info, the system simply splatters the file on the screen. If there is more data in the file than will fit on one screen, the contents whiz by before you can see it. The more command solves this problem by displaying the file screen by screen:
$ more dog_info
Affectionately known as the "Toller," the Nova Scotian Duck
Tolling Retriever was once called the Little River Duck Dog,
since it was developed in the Little River district of Yarmouth
County, Nova Scotia. This engaging dog is a specialist with
waterfowl. Tolling, or luring, is the practice of tricking ducks
into gunshot range. Hunters had long observed this behavior
The more command pauses when the screen fills up and waits for you to press the spacebar before it rolls out another screenful of text. A legend at the bottom of the screen tells you what percentage of the file has been displayed so far.
The less command works like more except that it lets you move both forward and backward in the file while the command is running--use the B key on your keyboard to back up one screen and the spacebar to move forward and show the next screen.
You can press Q to quit the more or less command.
Although all of these commands will let you view the contents of a file in different ways, none allow you to change the data in the file. If you want to view and update a file, use one of the text editors discussed in the "Text Editors" section.
Comments - most recent first
(Please feel free to answer questions posted by others!)
There's a way to break? Neither with ctrl-c works.
Thanks its short and understandable notes for
new in linux and want to learn. Nice job for us.
i give you thank from all who use this site.
Once again Thank you.
I want to know how to access the bin directory and can you briefly explain how to remove files from bin directory and what are all commands used to view the bin directories.
In advance tanks
NO SPAM! If you post garbage, it will be deleted, and you will be banned.
Copyright © by -
All rights reserved - Redistribution is allowed only with permission.