search

Home  >  Q&A  >  body text

linux - The online log file is very large, 200M. If you use VI to view it, it will freeze. How to search the content?

The online log file is very large, 200M. If you use VI to view it, it will freeze. How to search the content?

滿天的星座滿天的星座2744 days ago1150

reply all(4)I'll reply

  • typecho

    typecho2017-06-14 10:52:22

    You can use grep to search, supports regular expressions

    Or you can use head tail etc. to view the content of the head and tail

    Or use sed to view the content within the specified range. sed also supports string ranges, such as sed -nre '/regex1/,/regex2/p' log can print the log between the two matching regular expressions

    In addition, awk can display specified columns

    If there is really no available tool, you can use perl one-liner or script instead. Although this language is old, regular expressions are very powerful and worth learning

    reply
    0
  • 黄舟

    黄舟2017-06-14 10:52:22

    Use the less command.
    less file.

    reply
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-06-14 10:52:22

    To search, generally use cat file_name | grep search_string

    reply
    0
  • 迷茫

    迷茫2017-06-14 10:52:22

    Why not just grep?

    reply
    0
  • Cancelreply