File Content Check)

Source: Internet
Author: User
CAT (concatenate)
 
[Root @ WWW ~] #Cat[-Abentv] Options and parameters:-A: equivalent-Integration options of VET, which can list some special characters rather than blank;-B: list the row numbers. Only the row numbers for non-blank rows are displayed. blank rows are not marked with row numbers!-E: Display The End Of The Broken row byte $;-N: print the travel number, along with the blank line, with the line number, and-B's options are different;-T: Press [Tab] To ^I is displayed;-V: list special characters that cannot be seen

 

Review the content of the/etc/issue file

 
[Root @ WWW ~] #Cat/Etc/Issuecentos release5.3(Final) kernel \ r on an \ m

 

What if I want to print the row number?

[Root @ WWW ~] #Cat-N/etc/Issue1Centos release5.3(Final)2Kernel \ r on an \ m3# See it! You can print the row number! This is useful for finding a specific row for large files! # If you do not want to orchestrate the row numbers of blank rows, you can use 『Cat-B/etc/issue:

 

Display the content of/etc/xinetd. conf in full (including special bytes)

 [root @ WWW ~] #  CAT -A/etc/ xinetd. conf # $ .... (omitted in the middle ).... $ defaults $ {$ # the next two items are intended to be a quick access place to $ .... (omitted in the middle )....  ^ ilog_type ^ I = Syslog daemon  info  $  ^ ilog_on_failure ^ I =  host $  ^ ilog_on_success ^ I =  PID host duration exit $ .... (omitted in the middle ).... includedir /etc/ xinetd. d $ # the above results are limited to space. laruence deleted a lot of data. In addition, the output result does not contain any special font. # The special font on laruence allows you to find out where the difference is. Basically, in a general environment, # the effect of using [Tab] is similar to that of the blank key. They are all blank! We cannot know the difference between the two. # In this case, you can use   CAT -a to discover what is in the blank space! [Tab] is represented by ^  I, # The bytes of the broken line are represented by $, so you can find that every row is followed by $! However, the broken line bytes # are not the same in Windows /Linux. The broken line byte in Windows is ^  M $ Luo. # This part will be explained again in Chapter 10 Vim software introduction!  

Hey! Is there a "cat" command in Linux? Oh! No. Cat is the abbreviation of concatenate (continuous). Its main function is to continuously print the content of a file on the screen! For example, in the above example, we printed/etc/issue! If-N or-B is added, the row number is added before each row!

Little Cat is used by laruence! After all, when the number of lines in your file exceeds 40! It's too late to see the results on the screen! Therefore, it is better to wait for the more or less to be introduced! In addition, if it is a common DOS file, you need to pay special attention to some strange symbols, such as broken lines and [Tab, you have to add options like-!

 

TAC (reverse list)
 
[Root @ WWW ~] #Tac/Etc/Issuekernel \ r on an \ mcentos release5.3(Final) # Hey hey! Compared with the previous example, the last line is displayed first!

Tac! What should I do? For details, check whether CAT and tac have been found! Yes! TAC is just to reverse the cat, so its function is opposite to cat. Cat is displayed on the screen consecutively from the first line to the last line, while TAC is 『The last line to the first line is displayed on the screen in reverse direction.', Good time!

 

NL (add row number printing)
 
[Root @ WWW ~] #NL[-Bnw] File Options and parameters:-B: Specifies the row number in two ways:-B A: indicates that the row number is also listed (similarCat-N );-B T: if there are blank rows, do not list the row number (default) for the empty row );-N: There are three methods to list row numbers:-NLn: The row number is displayed on the leftmost side of the screen;-N rn: the row number is displayed on the rightmost side of its own column without adding0;-N rz: the row number is displayed on the rightmost side of its own column.0;-W: The number of digits occupied by the row number column.

 

Use NL to list/etc/issue content

[Root @ WWW ~] #NL /Etc/ Issue  1 Centos release 5.3  (Final)  2  Kernel \ r on an \ m # Note: There are actually three rows in this file, and the third row is blank (no bytes). # because it is a blank row  NL  No line number is added! If you are sure to add the row number, you can do this: [root @ WWW ~] # NL -B A/etc/ Issue  1 Centos release 5.3 (Final)  2  Kernel \ r on an \ m  3  # Haha! Add the row number to the arn ~ If you want to enable auto-increment before the row number  0  What about it? In this case, [root @ WWW ~] # NL -B A-N RZ/etc/ Issue  000001 Centos release 5.3  (Final)  000002  Kernel \ r on an \ m  000003 # Hey hey! It is automatically added to the position in its own column.  0 Now ~ The default field is six digits. If you want to change it 3  Number of digits? [Root @ WWW ~] # NL -B A-N RZ- W   3 /Etc/ Issue  001 Centos release 5.3  (Final)  002  Kernel \ r on an \ m  003  # Become only 3 Number of digits ~

NL can automatically add the row number to the output file content! The default result is a little different from cat-N. nl can compare the Display Design of Multiple row numbers, including the number of digits and whether to automatically complete 0.

 

More (one page and one page flip)

 

 
[Root @ WWW ~] #More/Etc/Man. Config # generated automatically fromMan. Conf.InBy the # configure script .##Man. Conf fromMan-1.6d... (Omitted in the middle )....-- More --(28%) <== Focus on this line! Your cursor will be here waiting for your command

Carefully show him the example above. If the number of lines of the file followed by more is greater than the number of lines output by the screen, a similar graph will appear. Focus on the last line. The last line shows the percentage currently displayed. You can also enter some useful commands in the last line! In moreProgramIn the running process, you have several buttons to press:

    • Blank key (Space): Indicates turning one page down;
    • Enter: Indicates turning "One Line" down 』;
    • /String: searches for the keyword "string" in the displayed content;
    • : F: displays the file name and the number of currently displayed rows immediately;
    • Q: The system immediately leaves more and the file content is no longer displayed.
    • B or [CTRL]-B: Indicates turning back the page. However, this action is only useful to files and useless to pipelines.

To exit the display of the more command, press Q to exit. To flip down the page, use the blank key. It is useful to search for strings. For example, we use "More/etc/man. config "to observe the file. If you want to search for the manpath string in the file, you can do this:

[Root @ WWW ~] #More/Etc/Man. Config # generated automatically fromMan. Conf.InBy the # configure script .##Man. Conf fromMan-1.6d... (Omitted in the middle )..../Manpath <= after/is input, the cursor automatically runs to the bottom line and waits for the input!

As described above, after entering/, the cursor will go to the bottom line and wait for your input. After you enter the string and press [enter], hey! More will start searching down the string ~ If you repeatedly search for the same string, you can simply press n! Finally, if you don't want to watch it, press Q to leave more!

 

Less (one page and one page flip)
[Root @ WWW ~] #Less/Etc/Man. Config # generated automatically fromMan. Conf.InBy the # configure script .##Man. Conf fromMan-1.6d... (Omitted in the middle )....:<= You can enter the command here!

The usage of less is more flexible than that of more. How can this problem be solved? At the time of more, we could not flip forward, but we could only look at it later. However, if less is used, haha! You can use the [Pageup] [Pagedown] and other buttons to access and view the file. You can see if it is easier to use to view the content of a file!

In addition, you can have more "Search" functions in less! You can not only search down, but also search up ~ It is really good to use ~ Basically, you can enter the following commands:

    • Blank key: Scroll down a page;
    • [Pagedown]: Scroll down a page;
    • [Pageup]: returns a page up;
    • /String: searches down for the "string" function;
    • ? String: the "string" search function is enabled;
    • N: Repeat the previous search (and/or? Related !)
    • N: Repeat the previous search (and/or? Related !)
    • Q: Leave the less program;

Actions that can be searched for by checking the File Content ~ Look ~ Is less useful! In fact, less has many functions! Use man less for detailed usage! Pai_^

Do you think the image and environment used by less is very similar to that of man page? That's right! Because the man command calls less to display the content of the instruction file!

 

Head (retrieve the first few rows)
[Root @ WWW ~] #Head[-N number] File Options and parameters:-N: Followed by a number, which indicates the number of rows displayed [root @ WWW~] #Head/Etc/Man. Config # The first 10 rows are displayed by default! To display20You have to do this: [root @ WWW~] #Head-N20/Etc/Man. Config

 

If the data in the last 100 rows is not printed, only the first few rows of/etc/man. config are printed. What should I do?

 
[Root @ WWW ~] #Head-N-100/Etc/Man. Config

The head is the "Header", so the usage of this item is naturally to show the first few lines of a file! That's right! That's it! If the-n option is not added, only 10 rows are displayed by default. What if only one row is required? Add "head-N 1 filename!

In addition, the parameters after the-n option are more interesting. If the number is negative, for example, in the example above-n-100, it indicates all the rows before the column, but does not include the last 100 rows. For example,/etc/man. config has a total of 141 lines, then the above command "head-n-100/etc/man. the first 41 rows are listed, and the last 100 rows are not printed.

 

Tail (retrieve the following rows)
[Root @ WWW ~] #Tail[-N number] File Options and parameters:-N: Followed by a number, which indicates the meaning of several rows.-F: indicates the file name followed by the continuous detection. Wait until you press [CTRL]-C will end tail detection [root @ WWW~] #Tail/Etc/Man. Config # the last 10 rows are displayed by default! To display the last20You have to do this: [root @ WWW~] #Tail-N20/Etc/Man. Config

 

If you do not know the number of rows in/etc/man. config, but only want to list data after 100 rows?

 
[Root @ WWW ~] #Tail-N +100/Etc/Man. Config

 

Continuous detection of/var/log/messages content

 
[Root @ WWW ~] #Tail-F/var/log/Messages<= The detection of the tail command will not be performed until [crtl]-C is entered.

 

From http://vbird.dic.ksu.edu.tw/linux_basic/0220filemanager_3.php

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.