我正在尝试按照本指南在 Azure 上测试 Django: https://github.com/carltongibson/rest-framework-tutorial/blob/master/docs/azure/2-appservice.md ,但是我一直坚持运行以下命令,因为我是从 PowerShell 执行此操作的:
$ 导出 $(grep -v '^#' .azure-env | xargs)
PowerShell 中的命令是什么?有人可以解释一下它的作用吗?
谢谢
最佳答案
shell 命令的描述已在您提供的文档中。
$ export $(grep -v '^#' .azure-env | xargs)
This uses grep to go through your .azure-env file excluding any lines that are comments, passing any values into
xargs
so they will be formatted to be interpreted by the shell. We then export these so they´re passed as environment variables to the commands we envoke.
您可以将 shell 命令转换为 PowerShell,如下所示:
Get-Content .\azure.txt | Select-String -NotMatch "^#" | ForEach-Object {
$array= $_[0].ToString().split("=")
[System.Environment]::SetEnvironmentVariable($array[0], $array[1])
}
结果截图如下:
关于django - powershell中的bash导出命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54647001/