If you create a directory and a file like this
mkdir 'x ./'
touch 'x ./ x.c'
and try the find command, you will have a match
x ./ x.c
Now if you pipe this into xargs rm you don't have just one path. You have three
x
./
x.c
The middle one is the current directory. So all will be gone.

You are right. The command is not safe.

But you should anyway understand a command before using it.

The sudo command seems pointless here. Giving recursive flag (-r) to rm doesn't make sense since you seem to have been only trying to delete files, not whole directories. In the example I gave having rm without the flag would only delete the .c file.

Hope you get your files back.

Reply via email to