Bash上的反向勾号的cmd/PowerShell等价于什么? [英] What's the cmd/PowerShell equivalent of back tick on Bash?

查看:92
本文介绍了Bash上的反向勾号的cmd/PowerShell等价于什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重定向命令输出:

例如:

echo "Foo `./print_5_As.rb`"

将回显"Foo AAAAA"

would echo "Foo AAAAA"

推荐答案

PowerShell语法基于POSIX ksh语法 (有趣的是,不是使用任何一种Microsoft语言 例如CMD.EXE,VBScript或Visual Basic for Applications), 许多事情的工作原理与Bash差不多.在 您的情况下,命令替换是通过

The PowerShell syntax is based on the POSIX ksh syntax (and interestingly not on any of Microsoft's languages like CMD.EXE, VBScript or Visual Basic for Applications), so many things work pretty much the same as in Bash. In your case, command substitution is done with

echo "Foo $(./print_5_As.rb)"

在PowerShell和Bash中.

in both PowerShell and Bash.

Bash仍然支持古老的方式(反引号),但是 PowerShell清理了语法并删除了多余的 诸如两个不同命令替换的构造 语法.这样可以释放不同的反引号 在PowerShell中使用:在POSIX ksh中,反斜杠用作 逃脱字符,但是这在非常 PowerShell,因为反斜杠是传统路径 Windows中的组件分隔符.因此,PowerShell使用 (现在未使用)反引号进行转义.

Bash still supports the ancient way (backticks), but PowerShell cleaned up the syntax and removed redundant constructs such as the two different command substitution syntaxes. This frees up the backtick for a different use in PowerShell: in POSIX ksh, the backslash is used as escape character, but that would be very painful in PowerShell because the backslash is the traditional path component separator in Windows. So, PowerShell uses the (now unused) backtick for escaping.

这篇关于Bash上的反向勾号的cmd/PowerShell等价于什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆