LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Determine the size of each file in a folder. (https://www.linuxquestions.org/questions/linux-newbie-8/determine-the-size-of-each-file-in-a-folder-847453/)

ppj 11-30-2010 08:56 AM

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 .

stress_junkie 11-30-2010 08:58 AM

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

ppj 11-30-2010 09:04 AM

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

GrapefruiTgirl 11-30-2010 09:16 AM

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! :rolleyes:

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"

grail 11-30-2010 09:21 AM

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.

ppj 11-30-2010 09:34 AM

Friends, i fill like been bombared with answers ! =)

Thank you very much .


All times are GMT -5. The time now is 12:22 PM.