Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-30-2010, 09:56 AM   #1
LQ Newbie
Registered: Nov 2010
Posts: 4

Rep: Reputation: 0
Question Determine the size of each file in a folder.


i have a folder with 10 files and i would like to determine the size of each file.

i was trying the command
du -sh foldername
but i receive the total size . Any help, please .

Thank you .
Old 11-30-2010, 09:58 AM   #2
Senior Member
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 334Reputation: 334Reputation: 334Reputation: 334
Remove the s from the arument list. The s argument means to give a summary report for the entire directory.
du -h directoryname
You could have found this answer in the manual page for du.
man du

Last edited by stress_junkie; 11-30-2010 at 10:00 AM.
1 members found this post helpful.
Old 11-30-2010, 10:04 AM   #3
LQ Newbie
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
yep, thanks i fould it .

but i would like to ask , how it is possible Not to see the last line ? i mean the last line display the total size which i dont want it .


Last edited by ppj; 11-30-2010 at 10:36 AM.
Old 11-30-2010, 10:16 AM   #4
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
I'm curious... OP says he wants the sizes of 10 files in a given directory; when I run `du -h` I seem to be getting the sizes of all the directories within my current directory. Is that what OP wants?
Never mind above - I never gave it a directory name!

Well anyhow, here's a way to get rid of the last line of a list of lines:
du -h | head -n-1
And also, in case OP is interested, here's another (example) way of neatly printing the sizes and filenames of files in the current directory:
find . -maxdepth 1 -type f -printf "%-10s%f\n"

Last edited by GrapefruiTgirl; 11-30-2010 at 10:18 AM.
2 members found this post helpful.
Old 11-30-2010, 10:21 AM   #5
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,628

Rep: Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943Reputation: 2943
Actually du is showing you the size of the final file / directory found, which in this case is the . directory, ie the directory you are in.

Why not play a little with globbing and what the files all contain within their names.
Old 11-30-2010, 10:34 AM   #6
LQ Newbie
Registered: Nov 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Friends, i fill like been bombared with answers ! =)

Thank you very much .


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
Determine mp3 length by file size jmoschetti45 Linux - General 3 11-16-2010 08:19 PM
[SOLVED] Determine the size of file in a script tara Programming 3 06-24-2010 08:34 PM
shell script to determine if file size equals zero jonfa Programming 5 12-11-2007 05:48 PM
How to determine file system block size? provo1234 Linux - Newbie 2 02-14-2005 10:30 AM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 03:26 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:48 PM.

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