Transfering files between servers and making sure directory sizes match has lead me down a path of exploring the du command in detail – heres some helpful commands I’ve been using to list directory sizes. I’ve been using ubuntu but should work in debian etc too.
To list all top level directories
du -h -d 1To list all directories that match a directory name
du -hsc Name*this one lists top level where directory name stars with Name and the wildcard * at the end – Name, NameOne, NameTwo etc
Another handy feature is adding sort in reverse order with human readable sizes by piping the output into the sort command
du -hsc Name* | sort -hralso watching the directory sizes whilst transferring files is helpful!
watch -n 10 du -h -d 1where the -n 10 is the amount of seconds between refreshes
Leave a Reply