du only zip files

Hello,

I need to know how much space zip files take within a hierarchy of directories.
du -hs *.zip does not work.
du -hsc --exclude *.jpg gave me an idea but it is not quite right as there are other files than .zip and .jpg.

Any idea?

Thanks

I understand that I can exclude the zip files and I would get my answer by comparing to the the total without any exclusion but I'd like to know if one can specify types of files with du.

Hi.

du -ak | awk '/\.zip$/ {T+=$1} END {print T, "kilobytes"}'

du displays the space allocated to the file, not the size of the file itself - for that, use find / ls.

find . -name '*.zip' -exec du -sh {} \;

Hello ,
du -hs *.zip works for me.

gaurav@localhost:~$ du -hs *.txt
92K    crc_v3.txt
4.0K    exam_schedule.txt
4.0K    hello.txt
4.0K    my_txt_resume.txt
4.0K    quotes.txt
gaurav@localhost:~$ uname -a
Linux localhost 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux

Do you want to find the total size?


find . -name "*.zip" | xargs ls -ltr  | awk '{size+=$5} END { print size}'

Hello,

du -B 1K *.txt --max-depth=1 | awk '{size+=$1}END{print "size is\t"  size "K"}'

IT does to one level of depth in hierarchy, if however you want to search the subdirectories then replace the value of the option --max-depth=n where "n" is the depth you want to look for.
Regards.