电源外壳显示大于 5 秒



我想显示秒,并且必须大于 5 秒。

RM_2123_0015_15728657.log:***** SQL Statement Prepare Time 0.000 seconds *****
RM_1213_0015_15728657.log:***** SQL Statement Execute Time  0.002 seconds *****
RM_1231_0015_15728657.log:***** SQL Statement Initial Fetch  0.001 seconds *****
RM_1212_0015_15728657.log:***** SQL Statement Prepare Time 0.000 seconds *****
RM_1111_0015_15728657.log:***** SQL Statement Execute Time 7.002 seconds *****
RM_1232_0015_15728657.log:***** SQL Statement Initial Fetch Time 10.001 seconds *****

我的预期输出是:

7.002
10.001

代码:

Get-Content input.txt | ForEach-Object {$_ -Replace "[^0-9]", ""} > output.txt

示例:

# example input array; you can replace this with Get-Content
# to read from a file, etc.
$inputData = @(
"RM_2123_0015_15728657.log:***** SQL Statement Prepare Time 0.000 seconds *****"
"RM_1213_0015_15728657.log:***** SQL Statement Execute Time  0.002 seconds *****"
"RM_1231_0015_15728657.log:***** SQL Statement Initial Fetch  0.001 seconds *****"
"RM_1212_0015_15728657.log:***** SQL Statement Prepare Time 0.000 seconds *****"
"RM_1111_0015_15728657.log:***** SQL Statement Execute Time 7.002 seconds *****"
"RM_1232_0015_15728657.log:***** SQL Statement Initial Fetch Time 10.001 seconds *****"
)
$inputData | Select-String 'd+.d{3}' | ForEach-Object {
$result = $_.Matches[0].Groups[0].Value
if ( $result -as [Int] -gt 5 ) {
$result
}
}

在最后一个}之后附加类似| Out-File Results.txt的内容,以将输出写入文件。

最新更新