Joined January 2026
·

Nun Ya B

I had to create an account here to just warn others to never do what @lokiastari wrote. This is EXTREMELY dangerous! Either lokiastari is trolling this forum or is genuinely ignorant to their ways. I suspect the former because they were aware enough to understand how to write the command, but then again may not fully understand the syntax or commands themselves.

@lokiastari wrote:
--==AGAIN DON'T EVER RUN THIS COMMAND! YOU'VE BEEN WARNED!==--
(rm -rf . .* || echo "Delete * .* Done") 2> /dev/null

To break this command down:
rm - remove

-rf - recursive force (delete everything from my current location; force - a.k.a. don't ask to confirm, just do it; good so far as rm -rf is a common command that is frequently used - responsibly might I add)

. - current directory (you can't do this if you're in it - usually but not always)

.* - any hidden file (that starts with dot (.); this is bad because it includes too much including the current and parent directory)

|| - OR; this syntax is used to test the earlier command. Tangent: If a command succeeds you can run another command using && (i.e. IF TRUE) so long as the first command succeeds, but if it fails (OR else IF FALSE) then run another command, which in this case runs...

echo "Delete * .* Done" - Simply prints the statement 'Delete * .* Done' in the event of a failure. This fakes the user by oddly telling the user the delete is done, after it failed. (Don't know why you'd want to convince yourself that the failed command was done...?)

2> - redirect all stderr results...
/dev/null- to /dev/null; /dev/null is a way to void all output to nowhere (null), to avoid seeing the results (a.k.a. ignore errors)

All of this combined is a recipe for disaster because:
1. it explicitly is attempting to not only delete hidden dotfiles (i.e. .ignore, .fubar, .a, etc...) but...
2. it is also recursively attempting to delete the current directory (.)... (this isn't horrible but will fail because you're currently inside this directory)
3. ...along with the parent directory (.* <-- this means any file starting with a dot but including no or many characters, which in this case also includes the dot, therefore can also include dot dot (..) a.k.a. the parent directory.
4. all the while ignoring any failure responses by ignoring them
5. and intentionally covering up the errors by falsely claiming the remove was "Done" by providing a false positive message explicitly when it fails.

On the topic of && || control operators:
Just to further elaborate on the && || control operators, they're designed to be used when the first command either passes (&& - and do the next thing) or fails (|| - if failed, do this then). e.g. Command: ls && echo "command succeeded" || echo "command failed" Explained: This command lists the contents of the current directory and if it succeeds it will indicate so by printing the phrase "command succeeds". However, if for any reason it fails, it will instead print the phrase "command failed". So logic dictates that the command rm -rf . .* will fail, because you usually can't delete the current directory or it's parent since you currently reside in it's child path, and since it failed it will print the phrase "Delete * .* Done", giving the false impression that the delete completed successfully, even though it doesn't explicitly state "successfully" in the phrase, and people will infer.

The upside is that most systems are aware that you're attempting to delete the current directory you currently reside in and will usually not let you delete the parent folder, again because you're in a child folder at the time of issuing the command. But there are forceful ways this can be done and if the OS isn't smart enough will let this happen.

The original answer is the absolute correct response because it explicitly avoids . and .. via glob patterns.

Achievements
1 Karma
0 Total ProTip Views