CentOS File Content Query command

Source: Internet
Author: User

Document Content Query

Cat: displays the file content starting from the first line.

Tac: displays the file content starting from the last line

Nl: displays the row number.

More: displays the file content on one page.

Less: similar to more, but it can flip the page forward

Head: only the first few lines

Tail: only the last few rows

Touch: file creation and modification of file time

Cat (concatenate)

Syntax: cat [-AbEnTv]

Options and parameters:

-A: equivalent to the Integration parameter of-vET

-B: list the row numbers. Only the row numbers are displayed for non-blank rows.

-N: the output line number. Both blank and non-blank fields are listed.

-E: display the ending line break characters ¥

-V: lists some unreadable special characters.

-T: press the Tab key to display it with consumer I.

Example:

[root@localhost tmp]# cat /etc/issueCentOS release 5.10 (Final)Kernel \r on an \m[root@localhost tmp]# cat -n /etc/issue     1  CentOS release 5.10 (Final)     2  Kernel \r on an \m     3[root@localhost tmp]# cat -A /etc/issueCentOS release 5.10 (Final)$Kernel \r on an \m$$
Add row number and print (nl)

Syntax: [root @ www ~] # Nl [-bnw] File

Options and parameters:

-B: Specifies the row number in two ways:

-Ba: indicates that the row number (similar to cat-n) is also listed no matter whether the row is empty or not );

-Bt: if there are blank rows, do not list the row numbers (default value) for the empty rows );

-N: Used to list row numbers. There are three methods:

-Nln: the row number is displayed on the leftmost side of the screen;

-Nrn: the row number is displayed on the rightmost side of its own column without 0;

-Nrz: the row number is displayed on the rightmost side of its own column with a value of 0;

-W: The number of digits occupied by the row number column.

Example

[Root @ www ~] # Nl/etc/issue 1 CentOS release 5.3 (Final) 2 Kernel \ r on an \ m this file actually has three rows, the third row is blank (no bytes ), because it is a blank line, the nl will not add a line number. [root @ www ~] # Nl-B a/etc/issue 1 CentOS release 5.3 (Final) 2 Kernel \ r on an \ m 3 [root @ www ~] # Nl-B a-n rz/etc/issue000001 CentOS release 5.3 (Final) 000002 Kernel \ r on an \ m000003 automatically add 0 in the position of your own bar ~ The default field is six digits. If you want to change it to three digits? [Root @ www ~] # Nl-B a-n rz-w 3/etc/issue001 CentOS release 5.3 (Final) 002 Kernel \ r on an \ m003

Syntax: more | less file

More:

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.

Less:

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;

Example:

[root@localhost tmp]# more /etc/man.config ## Generated automatically from man.conf.in by the……..# and to determine the correspondence between extensions and decompressors.## MANBIN                /usr/local/bin/man#--More--(31%)
Extract the first few rows (head)

Syntax: head [-nnumber] File

Options and parameters:

-N: Followed by a number, indicating the number of rows

The default value of number is 10. When number is a negative number, it indicates listing all the preceding rows but not including the following number rows.

Remove the following lines (tail)

Syntax: tail [-nnumber] File

Options and parameters:

-N: Followed by a number, indicating the number of rows

The default value of number is 10. When number is positive (+ number), it indicates that the file will be listed after number.

File modification time | create a new file (touch)

Time attribute

Mtime (modificationtime): This time is updated when the file content data changes. The content data refers to the file content, excluding the file permissions and attributes.

Ctime (Statetime): This time is updated when the file state (permission and attribute) is changed.

Atime (accesstime): This time will be modified when the file content is used.

Example:

[Root @ localhost ~] # Ls-l -- time-style = long-iso/etc/man. by default, config modifies mtime-rw-r -- 1 root 4617/etc/man. config [root @ localhost ~] # Ls-l -- time = ctime -- time-style = long-iso/etc/man. config-rw-r -- 1 root 4617/etc/man. config [root @ localhost ~] # Ls-l -- time = atime -- time-style = long-iso/etc/man. config-rw-r -- 1 root 4617/etc/man. config

Syntax: touch [-acdmt] File

Options and parameters:

-A: only modify the access time atime

-C: only the time when the file is modified. If the file does not exist, no new file is created.

-D: the date to be modified. You can also use-date = "time or date"

-M: only modify mtime

-T: The time to be modified.

Main functions:

Create an empty file

Modify the file date (mtime, atime)

Example:

[Root @ localhost tmp] # cp-a/etc/man. config. /newman. config [root @ localhost tmp] # ls-l -- time-style = long-iso newman. config specifies the time format-rw-r -- 1 root 4617 newman. config [root @ localhost tmp] # touch-m-t 0709150203 newman. config // only modify mtime [root @ localhost tmp] # ls-l -- time-style = long-iso newman. config-rw-r -- 1 root 4617 newman. config [root @ localhost tmp] # ls-l -- time = atime -- time-style = long-iso newman. config // only modify atime-rw-r -- 1 root 4617 newman. config [root @ localhost tmp] # touch-a-t 0809150203 newman. config [root @ localhost tmp] # ls-l -- time = atime -- time-style = long-iso newman. config-rw-r -- 1 root 4617 newman. config [root @ localhost tmp] # [root @ localhost tmp] # touch-d "2 days ago" newman. config // atime and mtime [root @ localhost tmp] # ls-l -- time = atime -- time-style = long-iso newman are modified by default. config-rw-r -- 1 root 4617 newman. config [root @ localhost tmp] # ls-l -- time-style = long-iso newman. config-rw-r -- 1 root 4617 newman. config

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.