LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-04-2009, 03:39 AM   #1
respex
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
How can I find the total disk space used by all files with the same extension (*.dat)


I'm running SLES10 SP2 and using the XFS filesystem

Thanks in advance
respex
 
Old 12-04-2009, 04:51 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
AS long as they are all in one dir you can use du
Code:
 du -hsc ./*.pet
4.0K    ./10.pet
4.0K    ./11.pet
4.0K    ./12.pet
4.0K    ./13.pet
4.0K    ./14.pet
4.0K    ./15.pet
4.0K    ./16.pet
4.0K    ./17.pet
4.0K    ./18.pet
4.0K    ./19.pet
4.0K    ./1.pet
4.0K    ./20.pet
4.0K    ./2.pet
4.0K    ./3.pet
4.0K    ./4.pet
4.0K    ./5.pet
4.0K    ./6.pet
4.0K    ./7.pet
4.0K    ./8.pet
4.0K    ./9.pet
80K     total
 
Old 12-04-2009, 05:09 AM   #3
respex
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Unfortunately the files are not all in the same dir.
 
Old 12-04-2009, 05:19 AM   #4
JML
LQ Newbie
 
Registered: Jan 2005
Location: TN
Distribution: Fedora, Debian, Arch
Posts: 4

Rep: Reputation: 1
find / -iname '*.dat' -type f -print0 | xargs -0 du -hsc

Change / in the find to something more appropriate, / tells it to start at the root of the drive so that may not be what you want and will take longer. The -type f part tells it to only look for files, not directories. The -print0 and xargs -0 makes things cleaner when passing to du (disk usage).
 
1 members found this post helpful.
Old 12-04-2009, 05:52 AM   #5
respex
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Original Poster
Rep: Reputation: 0
Thumbs up

Cheers JLM - that looks exactly what I'm after.
 
Old 12-04-2009, 06:38 AM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by respex View Post
Unfortunately the files are not all in the same dir.
then check du's man page. there's an option for recursive listing.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the total number of files in a folder cnm Linux - Newbie 18 08-25-2015 01:01 AM
How to find grand total size of all files in a directory fakhrul Red Hat 4 04-17-2010 12:28 AM
How much total Hard Disk Space required to install RHEL AS 5.0 singh_chitranjan Linux - Newbie 3 06-24-2008 01:30 PM
How program to read files with extension .dat y .cfg files COMTRADE in fedora 1? ivonne Linux - Software 0 11-22-2004 11:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration