作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我试图在Powershell中使用-match查找字符串“ErrorCode”:1。我发现许多文件带有ErrorCode:1。问题是,当我打开一个由匹配表达式给出的文件进行检查时,我什至没有找到单词ErrorCode,而文件名仍然作为输出提供给我
我试图检查文件,但是许多文件都有我要搜索的字符串,但是许多文件却没有。
$fileNames = Get-ChildItem -Path $scriptPath -Recurse -Include *.data
$FoldersToRename = @() #initialize as array
foreach ($file in $fileNames) {
If (Get-Content $file | %{$_ -match '"ErrorCode":1'})
# If (Get-Content $file | %{$_ -match '"ErrorCode": [1-9]\d*'})
{
$FoldersToRename += Split-Path $file
echo $file
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Not Found</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Not Found</h2>
<hr><p>HTTP Error 404. The requested resource is not found.</p>
</BODY></HTML>
最佳答案
尝试分隔Get-Content命令。
$fileNames = Get-ChildItem -Path $scriptPath -Recurse -Include *.data
$FoldersToRename = @() #initialize as array
foreach ($file in $fileNames) {
$content = Get-Content $file
If ($content -match '"ErrorCode":1'})
# If (Get-Content $file | %{$_ -match '"ErrorCode": [1-9]\d*'})
{
$FoldersToRename += Split-Path $file
echo $file
}
}
关于powershell - 即使没有人也能比赛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58300299/
使用 Git 或 Mercurial,当您进行克隆或 pull 时,您如何知道没有人 checkin 文件(推送)?重要的是: 1) 您永远不知道它处于不一致状态,因此当您的代码处于不一致状态时,您尝
我是一名优秀的程序员,十分优秀!