# Bash Commands ## Find ### Find and delete Find and delete command ```bash find / -name .DS_Store -delete ``` Alternative find and delete command ```bash find / -name ".DS_Store" -exec rm {} \; ``` the previous command is due that not all `find` have a delete funcion but with overhead of new process `-exec`. Find and delete with no overhead ```bash find / -name .DS_Store -print0 | xargs -0 rm ``` ## du du - estimate file space usage [man-page](https://man7.org/linux/man-pages/man1/du.1.html) [example How to Get the Size of a Directory in Linux](https://linuxize.com/post/how-get-size-of-file-directory-linux/) ```bash sudo du -sh /var # Output 85G /var ``` ```bash sudo du -shc /var/* # Output 24K /var/db 4.0K /var/empty 4.0K /var/games 77G /var/lib 4.0K /var/local 0 /var/lock 3.3G /var/log 0 /var/mail 4.0K /var/opt 0 /var/run 196K /var/spool 28K /var/tmp 85G total ``` ```bash sudo du -h /var/ | sort -rh | head -5 # Output 85G /var/ 77G /var/lib 75G /var/lib/libvirt/images 75G /var/lib/libvirt 5.0G /var/cache/pacman/pkg ```