如何在 PowerShell 中执行“dir/s/b"? [英] How do I do 'dir /s /b' in PowerShell?
问题描述
我有一个包含三个文件的文件夹,并希望在 PowerShell 中使用等效的 dir/s/b
.我该怎么做?
I have a folder with three files and want the equivalent of dir /s /b
in PowerShell. How do I do that?
例如,如果文件夹名称为 temp3
并且它包含三个文本文件 - a.txt
.b.txt
和 c.txt
,做
For example, if the folder name is temp3
and it contains three text files - a.txt
. b.txt
, and c.txt
, doing
C:\temp3> dir /s /b
给我
C:\temp3\a.txt
C:\temp3\b.txt
C:\temp3\c.txt
如何在 PowerShell 中获得 相同 结果?
How do I get the same result in PowerShell?
推荐答案
如果您将 Powershell 用作外壳程序(而不是脚本处理器),您只需键入:
If you are using Powershell as a shell (and not as a script processor), you can simply type:
cmd /r dir /s /b
/r
标志告诉 cmd.exe
运行命令并退出.换句话说,您将在相同的执行上下文中结束.
The /r
flag tells cmd.exe
to run the command and exit. In other words, you'll end at the same execution context.
对于许多命令来说,cmd/r
比处理 Powershell 面向对象架构要好.
For many commands, cmd /r
is better than dealing with Powershell object-oriented architecture.
这篇关于如何在 PowerShell 中执行“dir/s/b"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!