Linux has
several applications that allow you to view and manipulate text files at the
shell prompt. These applications are fast and best suited to manipulating the
plain text files of configuration files
Command for displaying content of
file:
- cat filename - Displays the content of file
- more filename - Browse through a text file
- less filename - Same as more but more features than more
- head filename - Output the begning (or top) portion of file
- tail filename - Output the ending (or bottom) portion of file
Cat stands for "catenate." It
reads data from files, and outputs their contents. It is the simplest way to
display the contents of a file at the command line
cat file.list
2. more
More is a filter for paging through text
one screen at a time. It does not provide as many options or enhancements as less,
but is nevertheless quite useful and simple to use
more file.list
SPACE - For moving page by page
ENTER -
For moving word by word
q - For quit
3. less
Less is a program similar to more, but which allows backward
movement in the file as well as forward movement. Also, less does not have
to read the entire input file before starting, so with large input files it
starts up faster than text editors like vi
less file.list
4. head
The head command reads the first few
lines of any text given to it as an input and writes them to standard output, by default “head” prints the first 10 lines of a
file
head file.list
By default
“head” prints the first 10 lines of a file
head -20
file.txt
Using -20 for more line to be displayed, you can use as many as you want
to see.
5. tail
The tail command
reads the last few lines of any text given to it as an input and writes them to
standard output, by default “tail” prints the last 10 lines of a
file
tail file.list
By default “tail” prints the last 10 lines of a
file
tail -20 file.list
Using -20 for more line to be displayed, you can use as many as you want
to see.
Display Content of File
Reviewed by vijay pratap singh
on
March 31, 2017
Rating:
No comments: