Just specify the recurse parameter as suggested:
rm -r app
If the folder contains hidden or read-only files, add the -Force
parameter:
rm -r -fo app
This is the short form of:
Remove-Item -Recurse -Force -Path app
If you do not have proper access rights, then you can of course not delete it.
Background
rmdir
and rd
are commands (not executables) you can call on the command prompt. rm
is not available by default. All three terms may also point to executables if you have a MinGW environment installed, for example. But they will not be available in PowerShell, because PowerShell uses those words as aliases for the cmdlet Remove-Item
:
PS> 'rm', 'rmdir', 'rd' | Get-Command
CommandType Name Version Source
----------- ---- ------- ------
Alias rm -> Remove-Item
Alias rmdir -> Remove-Item
Alias rd -> Remove-Item
If you have some of the tools available as executables, you can still access them in PowerShell by specifying the full path to them, like:
PS> C:\path\to\MinGW\msys\1.0\bin\rm.exe
But let's stick to Remove-Item
. As it is a cmdlet, it expects certain parameters or switches, like -Recurse
. You can abbreviate them until to that point, they remain unambiguous compared to other possible parameters. Therefore you can use:
rm -r
which looks like in bash, for example, where you can also pass two parameters like this:
rm -rf
When you send this command to PowerShell, it will try to match -rf
to a parameter that begins with rf
, which does not exist. In PowerShell you have to pass each parameter individually to a cmdlet. To pass the -Force
parameter, you have to write at least -fo
, because there is also a parameter -Filter
and thus -f
would be ambiguous.
In conclusion, to get the equivalent of rm -rf
from bash in PowerShell, you have to write at least:
rm -r -fo
rd /q /s
is for CMD, but it looks like you're running PowerShell. Nothing stops you from using CMD instead. And this question has absolutely nothing to do with the terminal you're using. It's a shell question.Remove-Item : A positional parameter cannot be found that accepts argument '/s'.
. I can easily delete the folder using git bash too. But that doesn't answer my question. Of course, it has relation because the new Windows Terminal Preview will be default soon from programmers. It has potential. Give it a shot & you'll see. I just need to delete the folder using that new Terminal. I don't understand why it's so hard to understand.rd
is an alias forremove-item
and doesn't support the same syntax as CMD'srd
command. Open a CMD shell to runrd /q /s
-- in whatever terminal or console you prefer. If you run cmd.exe from Explorer, you'll get the classic conhost.exe terminal. In Windows Terminal you can run CMD in a new tab, or just run cmd.exe from PowerShell.