0

This question already has an answer here:

I am looking for all .zip and .rar files in comp_tuts folder and I am intersted in showing their file sizes and sorting them from biggest to smallest.

I have tried

ls -R *.zip

ls: cannot access *.zip: No such file or directory

What??

I have tried this:

find / size +50M */comp_tuts/*.zip

For some reasong it's completely ignoring my path and starts at /usr/lib or whereever.

I have also tried

du -sh *.zip
du: cannot access ‘*.zip’: No such file or directory

marked as duplicate by goldilocks, Archemar, terdon Jul 28 '15 at 12:27

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

The possible duplicate Link answered the question partly. To provide multiple name patterns to 'find' use this

find $directory -type f \( -name "*.zip" -o -name "*.rar" \)

The complete answer to the question is:

find $directory -type f \( -name "*.zip" -o -name "*.rar" \) -print0 | xargs -0 -n1 du -b | sort -n -r

with $directory being comp_tuts/ dir

  • Please explain your answer and I'll mark it as answer – Marko-A Jul 28 '15 at 11:31
  • Did you check the Link provided by Evgeny? It is pretty well explained there. I just added the first part with find being able to look for .zip aswell as .rar – lneb Jul 28 '15 at 11:43
0

With zsh:

print -rl -- **/*.(rar|zip)(DoL)

Replace with ls -lUd -- if you want to see ls -l information about them (-U being a GNU extension).

Note that it sorts by size, not disk usage.

  • I get bash: syntax error near unexpected token `(' – Marko-A Jul 28 '15 at 13:38
  • @Marko-A, I did say with zsh. zsh is a different shell from bash. – Stéphane Chazelas Jul 28 '15 at 13:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.