One day Linux Command (10) cat more less head tail file content display

Source: Internet
Author: User

Cat, more, and less are commonly used. In addition, if you want to view a large file (several hundred MB), but we only need the following lines of words, you need to use the tail command, Tac command can also be used for this purpose.

CatSyntax for displaying file content starting from the first line: CAT [-abeensttuv] [-- help] [-- version] filename
Note: connect the file string to the Basic output (screen or add> filename to another file ). Cat is short for concatenate (continuous ).
Parameters:
 -N or -- number: Number of the output rows
  -B or -- number-nonblank is similar to-N, but the blank row is not numbered. 
-S or -- Squeeze-blank will show only one row of blank rows consecutively
-V or -- show-nonprinting example:
Example 1: add the row number to the file content of textfile1 and enter textfile2.
$ Cat-N textfile1> textfile2
Example 2: Add row numbers (blank rows are not added) to the file content of textfile1 and textfile2, and then append the content to textfile3.
$ Cat-B textfile1 textfile2> textfile3
Example 3: CAT/dev/null>/etc/test.txt clears the file content of/etc/test.txt.
TAC is displayed from the last line. It can be seen that TAC is Cat's inverted write more page by page to display the file content Syntax: more [-dlfpcsu] [-num] [+/pattern] [+ linenum] [filenames...]
Note: It is displayed on one page. The most basic command is to pressSpace is displayed on the next page., PressKey B is displayed on the back page.And can be searched for strings (similar to VI). For instructions in use, press H. Parameters:-<Num> Number of lines displayed at a time
-D prompts the user. Text prompts when an error occurs, rather than 'beeps'
-L cancel the function that will be paused when a special character ^ L (Paper delivery character) is encountered
-F indicates the number of rows calculated based on the actual number of rows, rather than the number of rows after the automatic line feed (some rows with too long words will be extended to two or more rows)
-P does not display each page in a scroll mode, but clears the screen before displaying the content.
-C is similar to-P. The difference is that the content is displayed before other old data is cleared.
-S: if there are two or more blank rows in a row, it is replaced by a blank row.
-U does not display the quotation marks (it varies depending on the terminal specified by the Environment Variable term)
 +/Search for this string (pattern) before each file is displayed, and then start to display it after this string.
  + <Num> display starting from row numExample 1: show the LS content one page at a time $ LS-Al | moreLess is similar to more, and the advantage is that you can flip the page forwardSyntax: less [Option] filename
Note: You can use the [Pageup], [Pagedown] and other buttons to flip the file forward and backward. At the same time, because less does not read the entire file at the beginning, opening a large file will be faster than the general document Editor (such as VI. Press the key:/word: Search for the word string in the file. Q: exit the less picture head. Only the first few lines of syntax: head [-N number] [file name] parameter description:-N: display number rows. by default, only the first 10 rows of tail are displayed. Similar to head Example 1: To display ~ /. 11th ~ of bashrc ~ 20 rows. You can first fetch the first 20 rows and then the last 10 rows. $ Head-N 20 ~ /. Bashrc | tail-N 10Line number output at the same time when NL is displayedOd reads File Content in binary modePresented in octal characters

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.