LinuxQuestions.org
Review your favorite Linux distribution.
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 11-30-2010, 09:56 AM   #1
ppj
LQ Newbie
 
Registered: Nov 2010
Posts: 4

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


Hello,

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

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

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

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Remove the s from the arument list. The s argument means to give a summary report for the entire directory.
Code:
du -h directoryname
You could have found this answer in the manual page for du.
Code:
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
ppj
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 .

Thanks

Last edited by ppj; 11-30-2010 at 10:36 AM.
 
Old 11-30-2010, 10:16 AM   #4
GrapefruiTgirl
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:
Code:
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:
Code:
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
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,244

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
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
ppj
LQ Newbie
 
Registered: Nov 2010
Posts: 4

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

Thank you very much .
 
  


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
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


All times are GMT -5. The time now is 02:49 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