Timeline for Sorting files according to size recursively
Current License: CC BY-SA 4.0
23 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 31 at 19:43 | comment | added | WesternGun | Hi @slm, do you know how to merge the dirs with same base path? For example in your output, 3.8G /home/saml/Downloads/audible and 3.8G /home/saml/Downloads/audible/audio_books actually only shows one big dir which is the 2nd one. I'd like to exclude the 1st one and only get the longest path. | |
| Dec 7, 2022 at 1:17 | history | edited | slm♦ | CC BY-SA 4.0 | added 3 characters in body |
| S Dec 7, 2022 at 1:16 | history | rollback | slm♦ | Rollback to Revision 3 - Edit approval overridden by post owner or moderator | |
| Dec 6, 2022 at 9:41 | history | suggested | bridgemnc | CC BY-SA 4.0 | I think that using .. in placeholder is misleading as it itself means something in case of shell commands (.. - go to parent directory) |
| Dec 5, 2022 at 6:26 | review | Suggested edits | |||
| S Dec 7, 2022 at 1:16 | |||||
| Aug 4, 2021 at 10:40 | comment | added | Kamil Dziedzic | How about listing only directories, I'm not interested in files. | |
| S Sep 11, 2020 at 14:13 | history | suggested | odony | CC BY-SA 4.0 | add variant to filter out *all* directories, aka the most common question under this answer ;-) |
| Sep 11, 2020 at 8:44 | review | Suggested edits | |||
| S Sep 11, 2020 at 14:13 | |||||
| Sep 11, 2020 at 8:35 | comment | added | odony | @JanWarchoł I could not find any way for du to provide a different output for directory (-S changes their size, not the output format). So I resorted to a workaround that assumes that your directory names do not have any dots in them, and that the files you care about do. In that case you can replace the non-working grep -v '/$' by grep -v '\s/[^.]*$'. And you have to make sure you specify DIR as an absolute path, so there is no dot in there. | |
| Jul 5, 2020 at 5:21 | comment | added | nyanpasu64 | Use du --apparent-size to view the length of the file in bytes (not the size taken on disk). | |
| May 5, 2020 at 2:53 | comment | added | Student | @flochtililoch Super answer! It works for me :) | |
| Apr 16, 2020 at 1:12 | comment | added | flochtililoch | building on that solution, and the solution offered on this post: unix.stackexchange.com/questions/22432/…, I was able to yield a result with files only with the following command: find . -type f -exec du -ah {} + | grep -v "/$" | sort -rh | |
| Dec 16, 2019 at 14:51 | comment | added | demongolem | du --version in not an option for me, however the approach does work | |
| Feb 26, 2018 at 21:09 | comment | added | Roman Gaufman | This doesn't list just files, but also lists directories :( | |
| Aug 17, 2017 at 22:29 | comment | added | ekerner | This finds dirs also | |
| Feb 16, 2015 at 14:50 | comment | added | slm♦ | @JanekWarchol - incidentally to omit the directories you'll have to change tactics and use find to generate a list of files only and then have du tally them up. | |
| Feb 16, 2015 at 14:48 | history | edited | slm♦ | CC BY-SA 3.0 | deleted 2 characters in body |
| Feb 16, 2015 at 14:46 | comment | added | slm♦ | @JanekWarchol - Look at the 5th text box. The grep is just to filter the ~/Downloads/ bit out. As you've stated, it's just to filter out the argument of ~/Downloads when du processes it. I changed the word directories to directory since I think that's ultimately what was causing the confusion. Thanks for the feedback! | |
| Feb 16, 2015 at 13:55 | comment | added | Jan Warchoł | I'm on 8.13. But anyway, the output in your answer doesn't have trailing /s either - for example /home/saml/Downloads/audible seems to be a directory, but it doesn't have a slash. Only /home/saml/Downloads/ has a slash, but that's probably because you wrote it with a slash when specifying the argument for initial du. | |
| Feb 16, 2015 at 12:53 | comment | added | slm♦ | @JanekWarchol - what version of coreutils are you using? | |
| Feb 16, 2015 at 10:14 | comment | added | Jan Warchoł | The grep -v "/$" part doesn't seem to be doing what you expected, as the directories don't have a slash appended. Does anyone know how to exclude directories from results? | |
| Aug 24, 2013 at 19:00 | vote | accept | user2179293 | ||
| Aug 24, 2013 at 16:55 | history | answered | slm♦ | CC BY-SA 3.0 |