#the-internet

canoodle@nerdpol.ch

BE CAREFUL WITH find + delete - find . -delete -name vs find . -name -delete

one neat function of find, it that what it found can be passed to another function for further processing.

or: it can delete the file

BUT

this can go horribly wrong (and it does not ask for confirmation)

… deleting EVERYTHING in the current directory within the blink of an eye (depending on systems speed… terrabytes of data within seconds).

# warning! this can ruin one's day

<span style="color: #00ffff;">mkdir temp
cd temp
touch 1 2 3 f25020672.avi</span>

# only finds that file
<span style="color: #00ffff;">find . -name "*f25020672.avi*"
./f25020672.avi</span>

<span style="color: #ff0000;"># DANGER! THIS DELETES ALL FILES IN THE CURRENT DIRECTORY! NOT ONLY THE FILE BEHIND -name</span>
<span style="color: #00ffff;">find . -delete -name "*f25020672.avi*"</span>

# this would have been the correct way to do it
<span style="color: #00ffff;">find . -name "*f25020672.avi*" -delete
</span>

guess will have to powerdown, and continue when the backup-system of the backup-system is ready X-D

#linux #gnu #gnulinux #opensource #administration #sysops #accidental #delete #ext4 #trump #gnu-linux #the-internet #internet #lol #argh #fail #backups

Originally posted at: https://dwaves.de/2021/12/20/be-careful-with-find-delete-find-delete-name-vs-find-name-delete/