Linux traverses the same file name and calculates the sum of all file sizes

Source: Internet
Author: User


1. In the database of the sub-table, there may be different directories, the same file name, and we want to calculate

What is the size of the same data file, the following 1024 of the same file name, the method of calculating its size.


2. Ideas

1) Find out all the documents first

2) Check out the file size

3) Intercept File size column

4) Sum

[[Email protected]]# find/data/mysqldata-name t_traffic#p#p201612.ibd |xargs ls-l |gawk ' {print $} ' |wc-l1024[[email protected]]# find/data/mysqldata-name t_traffic#p#p201612.ibd |xargs ls-l |gawk ' {print $ {} ' |gawk ' BEGIN {SUM=0} {SUM+ =$1} END {print SUM} ' 2124496896[[email protected]]# find/data/mysqldata-name t_traffic#p#p201612.ibd |xargs ls-l |gawk ' {print $} ' |gawk ' BEGIN {sum=0} {sum+=$1} END {print sum/1024} ' 2074704[[email protected]]# find/data/mysqldata-name t_ TRAFFIC#P#P201612.IBD |xargs ls-l |gawk ' {print $ {} ' |gawk ' BEGIN {sum=0} {sum+=$1} END {print sum/1024/1024} ' 2026.08[[em Ail protected]]#


3. If you have a better way, please leave a message, learn together ~


Linux traverses the same file name and calculates the sum of all file sizes

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.