Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This a stupendously simple question.

How do I see the total bytes consumed by XML files in a subtree?

I've tried ls -R *.xml but it says No such file or directory

(I'm a Windows Engineer and C# Programmer of 16 years, and despite reading Linux books it does not stay in my head).

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Use find to search for files. ls shows everything starting at the given point, so if there is no xml file in the current directory, it cannot show anything. Use du to report the file size.

find . -name '*.xml' -exec du -b {} +
share|improve this answer
    
Wow. Just, wow. Can I get a total? –  Luke Puplett Jul 11 '13 at 11:17
1  
@LukePuplett: Sure. Just append | perl -lne '$s+=$_ }{ print $s' to the line. –  choroba Jul 11 '13 at 11:31
    
Just to confirm find . -name '*.xml' -exec du -b {} + | perl -lne '$s+=$_ }{ print $s' is the Linux equivalent of dir *.xml /s right? –  Luke Puplett Jul 11 '13 at 13:20
    
@LukePuplett: I do not know. dir might report much more than the pipeline. Have you tried it? –  choroba Jul 11 '13 at 13:35
1  
Some of that, yes. Else PowerShell can do anything really since its based on real .NET types. But again, we're back to having to eat an 800=page book to get a 2 second job done. –  Luke Puplett Jul 11 '13 at 16:56
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.