I have a directory structure where there are multiple symlinks at random depths.
For illustration purpose:
/fs /fs/afile /fs/blink -> /usr/local/lib /fs/cdir/cfile /fs/cdir/cdir/cdir/clink -> /var/log /fs/edir/edir/efile /fs/edir/elink -> /usr/local/bin
I want to find which file or folder utilizes the most space to do some cleanup. I am hoping an output similar to:
3.0G /fs 4.0G /fs/afile 3.3G /fs/cdir 15.0G /fs/edir
I tried running
cd /fs && find -maxdepth 1 -type d | sudo xargs du -hs but this expands the symlinks underneath, which means the size of
/fs/edir would include the content and size of
/usr/local/bin in this case.
TLDR: For a given path, how do I find the size of all files or directories at
depth=1, without expanding any underneath symlinks?
Note: I read du skip symbolic links but this case is different as the symlink in this case could be of any depth.