【发布时间】:2021-09-07 16:26:50
【问题描述】:
我正在尝试运行 PowerShell Core 中存在别名的 Bash 命令。
我想清除 bash 历史记录。示例代码如下:
# Launch PowerShell core on Linux
pwsh
# Attempt 1
history -c
Get-History: Missing an argument for parameter 'Count'. Specify a parameter of type 'System.Int32' and try again.
# Attempt 2
bash history -c
/usr/bin/bash: history: No such file or directory
# Attempt 3
& "history -c"
&: The term 'history -c' is not recognized as the name of a cmdlet, function, script file, or operable program.
问题似乎与 history 是 Get-History 的别名有关 - 有没有办法在 PowerShell 核心中使用别名运行 Bash 命令?
【问题讨论】:
-
我想你想要
bash -c history -c -
@briantist,我们的线在回答时交叉了(你是第一个);从语法上讲,它必须是
bash -c 'history -c'(单个-c参数),但是对于这个特定的命令,它实际上不起作用。我还在答案中添加了有关 Bash 的 CLI 的更多信息。
标签: powershell powershell-core