In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article focuses on "how to use the Shell+Linux command to achieve log analysis", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use the Shell+Linux command to achieve log analysis"!
1. List the IP with the most visits on the day
Command:
The code is as follows:
Cut-d-- f 1 / usr/local/apache2/logs/access_log | uniq-c | sort-rn | head-20
Principle:
The code is as follows:
Cut
-d,-- delimiter=DELIM
Use DELIM instead of TAB for field delimiter
Denote with-split, then-f 1
-f,-- fields=LIST
Select only these fields; also print any line that contains no
Delimiter character, unless the-s option is specified
The first part of the print is ip.
Uniq removes duplicate lines, and-c indicates that the number is preceded by a number.
Sort-rn is to sort the numbers from largest to smallest.
Head-20 take the first 20 lines
The final printed result looks something like this:
The code is as follows:
217 192.114.71.13
116 124.90.132.65
108 192.114.71.13
102 194.19.140.96
101 217.70.34.173
100 219.235.240.36
Here are some other shell uses for analysis logs:
1. Check the number of IP visits on the day:
The code is as follows:
Awk'{print $1} 'log_file | sort | uniq | wc-l
2. Check the number of times a page has been visited
The code is as follows:
Grep "/ index.php" log_file | wc-l
3. Check the number of pages visited by each IP:
The code is as follows:
Awk'{+ + S [$1]} END {for (an in S) print S [a]} 'log_file
4. Sort the number of pages visited by each IP from small to large:
The code is as follows:
Awk'{+ + S [$1]} END {for (an in S) print S [a], a} 'log_file | sort-n
5. Check which pages have been visited by an IP:
The code is as follows:
Grep ^ 111.111.111.111 log_file | awk'{print $1J 7}'
6. Remove the page for the day of search engine statistics:
The code is as follows:
Awk'{print $12 recording 1} 'log_file | grep ^\ "Mozilla | awk' {print $2}'| sort | uniq | wc-l
7. See how many IP visits were made during the 14:00 hour on June 21, 2009:
The code is as follows:
Awk'{print $4 print 1} 'log_file | grep 21/Jun/2009:14 | awk' {print $2}'| sort | uniq | wc-l
At this point, I believe you have a deeper understanding of "how to use the Shell+Linux command to achieve log analysis". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.