"Linux" To view log files with less

Source: Internet
Author: User

General programs are deployed in a Linux environment, and when viewing logs, typically less is used to meet most of the requirements.

Enumerating and documenting the most common scenarios, the code takes the Tomcat log file Catalna.out as an example.

View files directly
 Less Catalina.out

After viewing the file, if the file is too large, hit the following command to scroll the file:

J    Next line K    prev line f    Scroll down one screen b    scroll up one screen g    navigate to document head G    Navigate to the end of document

Exit View File

Q    Exit less mode

With line number view file

Log files generally have tens of thousands of lines, with line number display will be more convenient

 less-n catalina.out

Find content

When looking for keyword content, it's common to look down and look up. As found in the log, because the log is generally appended, from the bottom up to find more common.

/keyword down find n    matches next match text n    up match next match text?  Keyword up n    matches next match text n matches    next match text down

View document changes in real time (real-time scrolling documents)

After entering less mode, type F, which scrolls the document in real time

F    Real-time scrolling documents
Ctrl + C exits live scrolling mode similar effect:tail -F catalina.out

"Linux" To view log files with less

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.