如何在Windows cmd中组合TYPE和DIR命令?
我必须将 LINUX 命令转换为 Windows 命令。这是命令:
cat $(find folderName)/fileName
网上搜索发现:
cat
可以用type
翻译find
可以用dir
翻译>
所以我尝试使用这样的东西:
type @(dir folderName /s)/fileName
type < (dir folderName /s)/fileName
它们是错误的,但我找不到任何解决方案来组合它们。 有人可以帮助我吗?
I have to translate a LINUX command into a Windows one. This is the command:
cat $(find folderName)/fileName
Searching online I found that:
cat
can be translated withtype
find
can be translated withdir
So I tried to use something like this:
type @(dir folderName /s)/fileName
type < (dir folderName /s)/fileName
They are wrong, but I can't find any solution to combine them.
Can someone help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信其他人会提供
FOR
循环解决方案。如果您使用 PowerShell Core 或 Windows PowerShell,这并不困难。如果您使用的是受支持的 Windows 系统,则 Windows PowerShell 已随其安装并且可用。
虽然您可能会正确地说,这比 bash/ksh 脚本中所需的输入量要多,但它在 Linux、MacOS 和 Windows 上运行得同样好,无需任何修改。无需“翻译”。
使用别名可以减少输入量。虽然这在交互式 shell 中是可以的,但将别名编码到脚本文件中是不好的做法。
如果您迫切希望从
cmd
命令提示符运行此命令,可以使用以下命令。I am confident that others will provide
FOR
loop solutions.This is not difficult if you use PowerShell Core or Windows PowerShell. If you are on a supported Windows system, Windows PowerShell was installed with it and is available.
While you might rightly say that this is more typing than needed in a bash/ksh script, it will run equally well on Linux, MacOS, and Windows without any modification. No 'translate' needed.
The amount of typing can be reduced by using aliases. While that is ok at an interactive shell, it is bad practice to encode aliases into script files.
If you are desperate to run this from a
cmd
command prompt, the following could be used.