Sysadmins, find arguments are ordered, beware ⚠️ especially with -delete ☠️

$ ls
bar.txt foo.txt
$ find -delete -name foo.txt
$ ls

obviously -name should come first

Beware of the location you're in... Imagine if you're root, at /😅

Some have tried, they got problems... 😅

Yeah... After this incident, things got worst for him.

He was promoted as... CISO !

@carlchenet wooooow i'm gonna be super careful about that now thanks

@carlchenet find syntax is pretty hellish

I'm lucky to only have ever used it as find -[i]name 'pattern' -exec blah {} \;

@luna @carlchenet You’d rather use xargs, as -exec will for for each file.

For instance: `find . -iname foo -print0 | xargs -0 do-smth`

@Arcaik @carlchenet No? Most times I wanna run a command on each file individually because the program doesn't handle multiple inputs

Also find -exec has \; and \+, the latter does the same thing as xargs

@carlchenet general tip: it's more unixy and less risky to use find exclusively to /find/ files, then pipe it into xargs to actually do something with the list of results

@sir Indeed. Plus I always print the list with something like find … | xargs echo some variable before doing what I want to actually do (delete, move, execute some job… whatever) with that $variable.


Sign in to participate in the conversation

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!