Powershell 命令:rm -rf [英] Powershell Command: rm -rf
问题描述
rm
是删除item,但是参数-rf
是做什么用的?
rm
is to remove item, but what is the parameter -rf
do or signify?
每当我输入 help -rf 时,它都会在 powershell 中打印完整的可用命令列表.如果在 powershell 中键入 rm -rf 会发生什么?从阅读中我收集到它会删除驱动器上的所有内容?我不确定?
Whenever I typed help -rf it printed the entire list of available commands in powershell. What happens if you type rm -rf in powershell? From reading around I've gathered that it will delete everything on the drive? I'm not sure?
另外,rm -rf 是否与 rm -rf/相同
Also, is rm -rf same as rm -rf /
推荐答案
PowerShell 不是 UNIX.rm -rf
是 UNIX shell 代码,而不是 PowerShell 脚本.
PowerShell isn't UNIX. rm -rf
is UNIX shell code, not PowerShell scripting.
- 这是
rm
的文档(Remove-Item
的缩写)在 PowerShell 上. - 这是
rm
在 UNIX 上的文档.
- This is the documentation for
rm
(short forRemove-Item
) on PowerShell. - This is the documentation for
rm
on UNIX.
看到区别了吗?
在 UNIX 上,单独的 rm -rf
是无效的.您通过 remove 的 rm
和 recursive 和 f<的属性
r
告诉它要做什么/code> 表示 force,但您没有告诉它应该执行什么操作.rm -rf/path/to/delete/
表示 rm
(remove) 带有属性 r
(recursive) 和 f
(force) 在目录 /path/to/remove/
及其子目录中.
On UNIX, rm -rf
alone is invalid. You told it what to do via rm
for remove with the attributes r
for recursive and f
for force, but you didn't tell it what that action should be done on. rm -rf /path/to/delete/
means rm
(remove) with attributes r
(recursive) and f
(force) on the directory /path/to/remove/
and its sub-directories.
PowerShell 上正确的等效命令是:
The correct, equivalent command on PowerShell would be:
rm C:path odelete -r -fo
请注意,PowerShell 中的 -f
对于 -Filter
和 -Force
是不明确的,因此需要 -fo
可以使用.
Note that -f
in PowerShell is ambiguous for -Filter
and -Force
and thus -fo
needs to be used.
这篇关于Powershell 命令:rm -rf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!