linux - The online log file is very large, 200M. If you use VI to view it, it will freeze. How to search the content?
滿天的星座
2017-06-14 10:50:22
The online log file is very large, 200M. If you use VI to view it, it will freeze. How to search the content?
You can use
grep
to search, supports regular expressionsOr you can use
head
tail
etc. to view the content of the head and tailOr use
sed
to view the content within the specified range.sed
also supports string ranges, such assed -nre '/regex1/,/regex2/p' log
can print the log between the two matching regular expressionsIn addition,
awk
can display specified columnsIf 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 learningUse the
less
command.less file
.To search, generally use
cat file_name | grep search_string
Why not just grep?