Skip to main content

Große Ordner löschen (rm -rf)

Mit rm (inklusive Fortschrittsanzeige und Log)


https://unix.stackexchange.com/questions/255190/is-it-possible-to-determine-the-progress-of-an-rm-command 

Eikes Variante, um nur den Inhalt zu löschen und nicht den Ordner selbst (/* am Ende des Pfades hinter den Anführungszeichen):

rm -rfv "/ordner/mit/leerzeichen dazwischen/testordner"/* | pv -l -s $( du -a "/ordner/mit/leerzeichen dazwischen/testordner"/* | wc -l ) > /dev/null

 

I get the progress bar using pv command line Pipe Viewer

This is the command

rm -rv DIR_OR_FILE_NAME | pv -l -s $( du -a DIR_OR_FILE_NAME | wc -l ) > /dev/null

If you need root permissions for the dir or file to delete,

sudo rm -rv DIR_OR_FILE_NAME | pv -l -s $( sudo du -a DIR_OR_FILE_NAME | wc -l ) > /dev/null
  • rm -rv-r to recursively remove DIRs and files. -v verbose it lists all the files and directories that is removing.

  • pv -l -s-l to count lines instead of bytes. -s set the total lines to be removed.

  • $( du -a <dir_or_file> | wc -l )du -a returns a list all files and directories from the dir specified. wc -l returns the count of lines outputted by du -a.

  • > /dev/null: send the output of rm -rv to nowhere.