LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-18-2003, 03:29 PM   #1
phil1076
Member
 
Registered: Oct 2001
Location: Grand Cayman
Distribution: RH 9.0
Posts: 96

Rep: Reputation: 16
How to list total file size of a directory


Ok...so if I do a ls -la I get a list of all the files and their respective sizes. How can I get a summary of the total number of files and the size of all the files in the directory?

Thanks in advance.
 
Old 12-18-2003, 03:35 PM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Try du -h. du = Disk usage.
The -h switch makes the output human-readable (ie, instead of 1024 bytes, 1k is printed, 1024k = 1M, and so on). This will also include the size of all subdirectories.

Håkan
 
Old 12-18-2003, 03:37 PM   #3
Randy
LQ Newbie
 
Registered: Jun 2001
Distribution: Redhat
Posts: 18

Rep: Reputation: 0
Try doing a

$ du -h /dir

on the dir that you want to size.

To get the total number of files in a directory try this:

$ ls -l | wc -l

You can add these commands to a script if you ppan to use them often.

Hope this helps.
 
Old 12-18-2003, 03:47 PM   #4
phil1076
Member
 
Registered: Oct 2001
Location: Grand Cayman
Distribution: RH 9.0
Posts: 96

Original Poster
Rep: Reputation: 16
f

Yes, "du" is what I was looking for..thank you.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH : Total directory size xgreen Programming 7 03-04-2013 05:33 AM
finding size of total files in a directory blackzone Linux - Newbie 3 01-07-2005 03:01 AM
Total File Size meshcurrent Linux - General 1 05-17-2004 02:09 PM
Command to find total file size satimis Linux - Newbie 1 01-22-2004 11:19 AM
list size of directory and all directories it contains? ubien Linux - General 2 01-11-2003 10:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:20 AM.

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
Open Source Consulting | Domain Registration