我正在尝试执行以下操作 - 为当前目录中的每个 *.sql 文件运行
sqlplus username/password@connect_identifier_specified_in_argument @file_name
这是我目前所拥有的:
$scripts = dir *.sql
foreach($script in $scripts) {
Write-Host sqlplus username/password"@"$args "@"$script.Name
}
(我知道 Write-Host 会将其输出到屏幕上;我现在只是尝试调试。)
然而,PowerShell 处理 @
字符的方式有些奇怪,当我运行它时,我总是得到类似的东西:
PS C:\code\scripts> C:\utils\run_sql_scripts_on.ps1 identifier
sqlplus username/password@identifier @ ALERTS.sql
看到“@”后面的那个空格了吗?什么给了?
最佳答案
使用反引号 (`) 转义 @
。
Write-Host sqlplus username/password`@$args `@$script.Name
关于powershell - 如何在 PowerShell 中使用 @ 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/812882/