LinuxQuestions.org
Visit Jeremy's Blog.
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 08-01-2003, 01:18 AM   #1
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Rep: Reputation: 30
Red face To know the size of all files in a directory


Is there a command line quick way to show the size of all files in a directory (i.e. upto the depth of the directory tree)? Managed to do it with a script, although it doesn't traverse the whole directory tree associated with that directory.
 
Old 08-01-2003, 02:26 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
You mean like 'du --max-depth=[n]'?
 
Old 08-01-2003, 02:49 AM   #3
shaheen
LQ Newbie
 
Registered: Jul 2003
Location: India
Distribution: Red Hat 7.1
Posts: 27

Rep: Reputation: 15
To know the size of all files in a directory

Hi , i feel your problem is there are a lot of subdirectories under a single directory and you want to know the size of each file and the total size .. issue du -mh as the command in the console you will get a message like this

[shaheen@LocalServer shaheen]$ du -mh
8.0K ./.kde/Autostart
12K ./.kde
8.0K ./.ssh
696K .

I feel this is going to help .. do let me know ... all the best

Shaheen
 
Old 08-01-2003, 04:07 AM   #4
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
Hello shaheen,

so that means that all the files inside that directory and other subdirs, amount to 696K?

I mean, I want a facility just like Windows which gives you the total size of that folder (i mean, with all files, and files inside subdirectories, and so on...)
 
Old 08-01-2003, 04:38 AM   #5
shaheen
LQ Newbie
 
Registered: Jul 2003
Location: India
Distribution: Red Hat 7.1
Posts: 27

Rep: Reputation: 15
To know the size of all files in a directory

Dear ganninu , yes the command i posted displays the directory and the subdirectory list inside the directory from where you are issuing the command. So that 696k is the combined size of all the directory , subdirectory and the files inside them. I had other files inside the root directory thats why the file size showed 696k ,, du -mh doesnt show the size of files , thats reasonable bcos that is available by issuing ls -al /path/to/your/directory .. it will show the size of individual files ... but if you just want the complete size of all the files and the subdirectories inside the operable directory just issue that du -mh .. the last value is the combined size ,, but if you just want the complete size and not the individual size of the subdirectories ,, issue du -ksh ... you will only get that 696K not the subdirectory sizes .. i feel this is what you precisely want ... Hope this works , let me know if this clears out the problem ,, best of luck

Shaheen
 
Old 08-01-2003, 10:55 AM   #6
bloodsnake
LQ Newbie
 
Registered: Aug 2003
Posts: 1

Rep: Reputation: 0
ls -alR directory-name

(-R will do recursive)
 
Old 08-01-2003, 12:33 PM   #7
ganninu
Member
 
Registered: Jul 2003
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340

Original Poster
Rep: Reputation: 30
du -s <directory_name>| awk -F" " '{print $1}'

is all what i wanted. Thanks for the "du" idea guys... The size is printed in kilobytes by the way.
 
  


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
Script to delete files with 0k file size in a directory justgiver Linux - Newbie 4 01-28-2008 04:56 AM
Which directory contains files that normally change their size frequently? Simon Adebisi Linux - Software 4 06-28-2005 03:37 PM
finding size of total files in a directory blackzone Linux - Newbie 3 01-07-2005 03:01 AM
increase point size size when printing PDF files newlin Red Hat 0 09-27-2003 07:13 AM
trying to determine the size of all files in a directory riddlebox80 Programming 7 06-11-2003 07:27 PM

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

All times are GMT -5. The time now is 09:45 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
Open Source Consulting | Domain Registration