In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you how to deal with data through multiple location variables in shell, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Cat dd.txt
CourseId startTime endTime
107 1548471600 1548475200
337 1550455200 1550458800
337 1553306400 1553310000
As mentioned above, there is now a batch of data that needs to be uniquely identified by the three dimensions of courseId, startTime, and endTime (three variables), and then grouped in courseId for data statistics. I remember that there are location variables that can be realized, but it is a pity to forget that we can only ask for the second place. If there is a great god passing by, please give me some advice.
Cat dd.sh
#! / bin/bash
Username=account
Passwd=mima
Mysql-u$username-p$passwd-Bse "truncate table test.caidan"
While ["1" = "1"]
Do
Id= `cat dd.txt | head-1 | awk'{cat $1}'`
Start= `cat dd.txt | head-1 | awk'{cat $2}'`
End= `cat dd.txt | head-1 | awk'{cat $3}'`
Num1= `MySQL-u$username-p$passwd edusoho_e-Bse "SELECT COUNT (*) FROM course_member WHERE courseId=$id AND createdTime BETWEEN $start AND $end" `
Mysql-u$username-p$passwd-Bse "insert into test.caidan select $id,$num1"
Sed-I '1d' dd.txt
Num= `cat dd.txt | wc-l`
If [$num-eq 0]; then
Exit
Fi
Done
Grouping statistical results
SELECT id,SUM (num1) FROM `test`.`caidan` GROUP BY id ORDER BY NULL
These are all the contents of the article "how to process data through multiple location variables in shell". 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.