mkdocs/docs/bash.md
2021-10-13 01:05:46 +02:00

1.1 KiB

Bash Commands

Find

Find and delete

Find and delete command

find / -name .DS_Store -delete

Alternative find and delete command

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

find / -name .DS_Store -print0 | xargs -0 rm

du

du - estimate file space usage man-page

example How to Get the Size of a Directory in Linux

sudo du -sh /var

# Output
85G	/var
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
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