In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use AWK to achieve the comparison of two files", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use AWK to achieve the comparison of two files" this article.
Two files, test11.txt and test22.txt match, print out the content that matches the successful test22.txt
Root@ubuntu:/tmp# cat test11.txt aabbcc2daxdrraaffroot@ubuntu:/tmp# cat test22.txt aa 12132efea 90ifd abb 44cc 1232 432d 432a fdaxd 32rr feaa r32ff 22fdsail 00hell 001
Awk processing:
Root@ubuntu:/tmp# awk 'NR==FNR {a [$1] = 1} NR > FNR {if ($1 in a) print $0}' test11.txt test22.txt > result.txt root@ubuntu:/tmp# cat result.txt aa 12132bb 44cc 1232 432d 432a fdaxd 32rr feaa r32ff 22
Comments: the lines of the current NR file, the number of records read by FNR. NR=FNR when reading the first file
When the second file is read, FNR continues to count based on the first file. NR zeroing and re-recording.
When NR==FNR, process the first file
When NR > FNR, process the second file
Count the number of entries per minute in the log:
Cat access.log | awk-F ":"'{+ + S [$3]} END {for (i in S) print I "\ t" S [I]}'| sort-k1g
Minutes of time in $3-bit logging.
The-k 1g g parameter is similar to n, sorted by number
The above is all the contents of the article "how to use AWK to compare two files". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.