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