Linux File Viewer command:cat, TAC, more, less, tail, head

Source: Internet
Author: User

Text File View commands: Cat, TAC, more, less, tail, head, touch



Cat: Start all of the file contents from the first line

The cat command is a concatenate (continuous) shorthand for displaying the contents of the entire file on the screen, so there is a problem with the cat command, that is, when the entire file content is more than the screen size, we can only see the last display of the content on the screen, before the result is too late to see.


Cat: Connect and display the information of the file, which is all the information in the display file

-N: The line number can be displayed when displayed, this line number is only displayed, and the contents of the file is not related

-E: Displays the line terminator for each line, so the line terminator for the Linux Chinese text file is $

-T: Tabs can be displayed

-V: Display other nonprinting characters

-A: Show all symbols


TAC: Displays the contents of all files from the last line

The TAC command is the opposite of the cat command (as can be seen from the name), and the TAC command displays the contents of the file consecutively from the last line of the file to the screen content.


CAT,TAC command

Syntax: [OPTIONS] ... FILE:

Common parameter Options

-A: Show all content

Example:

#cat-A/etc/passwd


MORE: Page-by-page display of file contents

The role of More:more and Cat is the same, but at this time we can manually to flip screen, more convenient, more: only support backward, turned to the end of the direct exit less: Display file information, default does not exit display,

Q You can exit

Space: Turn Back one screen

B: Flip one screen forward

ENTER: Turn back one line

K: Turn forward one line

Keyword search

/keyword: Find Keywords

Less: page-by-page display of file content, but allows page forward

Tail: Show only a few lines at the end

Head: Show only the first few lines

More, less

Syntax: more [OPTIONS] ... FILE ...

Common parameter Options

-D: Display page with Exit prompt

Space: one screen backward;

Enter: one line backward;

B: one screen ahead;

Example:

# More-dc/etc/profile//Display prompt, and display from the terminal or the top of the console;

# more +4/etc/profile//starting from the 4th line of the profile display;

# more-4/etc/profile//Display 4 rows per screen;


Syntax: less [OPTION] ... FILE ...

Common parameter Options

Text Search:

/keyword

? KEYWORD

N: Next with the same direction as the command;

N: The previous one in the opposite direction of the command;

Example:

# less-n/etc/profile//Display line number

Tail,head: It's easier to use


Head: Displays the first few lines of the file, the default is 10 rows

-num: How many lines before display

Tail

Tail: Displays the following lines of the file, which is 10 rows by default

-num: How many lines are displayed after

-F: View the end of the file, and do not exit, waiting for the display of new additions;


Syntax: Head [OPTION] ... FILE

or tail [OPTION] ... FILE

Common parameter options:

-N #: Display before # line or after # line

Example:

# tail-n 5/etc/profile//Display the last 5 lines of the/etc/profile

# Head-n 5/etc/profile//Show front 5 lines of/etc/profile

-#


Touch: Time Stamp management tool:

Touch: Create a file

-C: Files are not created when they exist

-A: Only change the access time of the file//or--time=atime or--time=access or--time=use only change the access time.

-M: Change only the modified time of the file//or--time=mtime or--time=modify only change the change time

-T: Set the timestamp of the file (month and day), use//or with a, m to use the specified date time instead of the current time.

-D: Use the specified date time instead of the current time.

Each file has three timestamps:

Atime: The last time the file was visited;

Mtime: The last time the file was "modified";

CTime: The time the file was last "changed";


This article is from the "it_working" blog, make sure to keep this source http://weine100.blog.51cto.com/2152945/1691288

Linux File Viewer command:cat, TAC, more, less, tail, head

Related Article

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.