|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX Desktop for Dummies Questions & Answers Discuss UNIX and Linux user interfaces like GNOME, KDE, CDE, and Open Office here. All UNIX and Linux Newbies Welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Summing file sizes
I was just curious about how to sum the total file size of a certain type of file. For instance: Code:
$find . -name "*.aif" will print out the paths to each .aif file. Instead of printing, how could one sum the total space used by all of the aif files? Thanks!
Last edited by jim mcnamara; 12-01-2012 at 07:49 AM.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Try: Code:
find . -name "*.aif" -ls | awk '{s+=$7}END{print s/(1024*1024)" Mbytes"}' |
| The Following User Says Thank You to bartus11 For This Useful Post: | ||
Alexander4444 (12-03-2012) | ||
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Code:
find . -name "*.aif" -exec ls -l {} \; | awk ' { s+=$5 } END { printf "%d bytes\n", s } ' |
| The Following User Says Thank You to Yoda For This Useful Post: | ||
Alexander4444 (12-03-2012) | ||
|
#4
|
|||
|
|||
|
Thanks!
Thanks for these explanations! They work excellently. I especially appreciate the nice formatting of the output in Mb.
|
| Sponsored Links | ||
|
![]() |
| Tags |
| file size find ls |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Summing lines in a file | LearningLinux2 | UNIX for Dummies Questions & Answers | 6 | 10-15-2012 08:03 AM |
| HELP with Unix scripts in summing columns in a file | ramneim | Homework & Coursework Questions | 12 | 08-21-2012 03:54 PM |
| summing up the fields in fixed width file | srilaxmi | Shell Programming and Scripting | 2 | 04-07-2009 02:01 AM |
| Summing file size and output | ramkrix | UNIX for Advanced & Expert Users | 1 | 11-12-2008 12:30 PM |
| Summing the columns of a file | asahlot | Shell Programming and Scripting | 3 | 09-24-2008 09:18 PM |
|
|