The shell implements statistical views and saves the results to a file

Source: Internet
Author: User

Log files are one per day. A keyword in the statistics log file that gets the number of views per day. Save the number of times to the TXT file.

Save the date in the TXT file as well.

Enter a start date and an end date to count the number of times per day

The code is as follows:

#!/bin/sh#dateupdatebeg= $DateEnd= $CD/mnt/home/deploy/appserver/core/logs#Read Datebeg#Read DateEndBeg_s= ' date-d"$datebeg"+%s ' end_s= ' date-d"$dateend"+%s ' while["$beg _s" -le "$end _s" ] Dofiledate= ' Date-d @$beg _s+"%y-%m-%d"' echo$filedate>&gt, .... /zsy.txt && grep ' xxx url ' catalina-$filedate. out |wc-l >>.. /zsy.txt beg_s=$ ((beg_s+86400)) done

Run the file./dateup.sh 20171009 20171010

Open Zsy.txt and you can see the following:

2017-10-09

0

2017-10-10

0

The shell implements statistical views and saves the results to a file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.