Linux text file view, display command __linux

Source: Internet
Author: User
Linux text file view, display command
1, Cat Display file Content command.

Command format: #cat [[options]] < file list >
Common options:-B, calculates all non-null output lines, and begins with a line number of 1. -N to calculate all output lines (including blank lines) with the start line numbered 1. -S to replace multiple blank lines with a blank line. -E, add the $ symbol at the end of each line to make sure each row is easy to confirm, because some of the rows are too long and appear on the display as multiple lines on the display.

Instructions for command use:
Example:
Example A: Insert the Textfile1 file contents with the line number and enter textfile2 this file
#cat-N textfile1 > Textfile2
Example B: Append the contents of Textfile1 and Textfile2 to the textfile3 after adding the line number (blank line not added)
#cat-B textfile1 textfile2 >> textfile3
Example C: Displays the contents of the/etc/fstab file.
#cat/etc/fstab
2, head view file Header content command.
Command format:# head [[Options]] < file list >
Common options:-C,--bytes=size, print the SIZE byte content at the beginning of the file. -N,--Lines=number, the number line at the beginning of the file is printed, and the default is 10 lines ahead of the output. -Q indicates that the header of the file name is not displayed. -V, indicating the header to display the file name.

Command Usage instructions:
This command is used primarily to display the contents of my head in the file. To confirm that it is the file that we want to open or find.
Example:
Example A: For example, there is a filename "readme.txt" Under my/mnt/d directory, I want to see the contents of its first few lines, available commands:
# head /mnt/d/readme.txt
Macromedia
Flash Player 6 for Linux
Mozilla Plug-in and Standalone players
Update Version 6.0r79
4 March 2003
New In this Version
-------------------
See for the dir
3, tail View the file tail content command.
Command format: # tail [[options]] < file list
Common options:-C,--bytes=size, print the last SIZE byte content of the file. -N,--lines=number, prints the last number line of the file, which defaults to 10 lines ahead of the output. -Q indicates that the header of the file name is not displayed. -V, indicating the header to display the file name.

Instructions for command use:
Using this command is mainly used to display the contents of my tail file. To confirm that it is the file that we want to open or find.
Example:
Example a: In the previous example, if you want to see the contents of the following 10 lines, you can use the command:
#tail/mnt/d/readme.txt
2) Browser version
3) reproducible steps including a URL to the Web site where the
Problem was encountered.
If We need further information about a bug, you'll be contacted. An
Automated reply would be sent to assure your that we have received your
Bug. Due to the volume of mail received we are not able to
Individually respond to each.
4, grep lookup file Content command.
Command format:#grep [[options]] < matching characters > < file list >
Common options:-C, Count-l for matching rows, showing only file names that contain matching files. -H, do not display file names that contain matching files. -I, which produces a case-sensitive match, the default case is case-sensitive. -V to list rows that do not match.

Instructions for command use:
This command is used to display the search for a particular string in the terminal to find what matches the given pattern. In the file list, separate the files with a space.
Example:
Example a: Search for a matching character "text file" in file example.
#grep ' text file ' example
5, more paging display file command.
Command format: More[[options]] < filename >

Common options:-C, clear a line from scratch when the text is flipped, and then write the next line. Usually, more clears the screen and then writes each line. -N to create a display window that can display n rows. -D, display the action prompt: "Press space to continue, ' Q ' Quit", in place of more default prompts. -S to compress consecutive blank lines into one line. -P, do not roll the screen, clear the screen and display text.

Instructions for command use:
Use this command to display the contents of the file in a terminal screen.
Example:
Example A: pagination displays the contents of the file/root/log.txt.
#more/root/log.txt
6, less paging display file command
Command format:less [[options]] < filename >
Common options:-?, display the less help below the screen. -A to start the query after the last line displayed on the current screen. -C, full-screen rewrite from top row. -E, automatically exits less after the end of the file. The default press Q key exits. -N, remove the line number. -S to compress multiple contiguous blank lines into one line. -X N, specifies that the default value of N is 8 each time the tab is pressed to the N-grid. Instructions for command use:
This command is roughly the same as the more function, but less can press page up and PAGE down to play the pages forward or backward. And more does not have this function.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.