查找当前目录下所有包含"string1 string2"的文件*string*.dat

Find all files *string*.dat that contain "string1 string2" in the current directory

我需要在当前目录的数据文件中找到字符串 "substring1 substring2"。 我用的是Windows-10的cmd。 我根据 Windows 文档使用以下命令:

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/findstr#examples

findstr /c:"hello there" x.y 

通过这种方式它没有找到任何东西,尽管字符串存在。 当我使用不带 ':'

的相同指令时
findstr /c:"hello there" x.y 

它显示了 'hello' 的所有情况和 'there' 的所有情况。

具体案例如下:

findstr /c: "INVITE sip:" .\*5656*.dat
FINDSTR: Argoment not found after /c

请问。帮助

这对我来说很好用,所以我猜这是区分大小写的问题。您可能需要添加 /i,如下所示:

findstr /c:"INVITE sip:" /i *5656*.dat

你提到了without ':',但是命令和前一个一样(也许你的意思是"sip"之后没有冒号?)。如果参数中没有冒号,它将无法工作,字符串中的冒号可以正常工作。我不确定 findstr 是否单独查找单词 ("it shows me all cases of 'hello' and all cases of 'there'"),我无法做到这一点。由于冒号后的额外 space,您的最后一个示例也不起作用。

如果这根本不起作用,文件是否在子文件夹中?您是否尝试过更简单的术语,然后开始向字符串中添加单词?他们有什么特殊字符吗?

更新

根据您的意见,输出的字符串中可能有回车 return 字符,因此您可以将控制台输出重定向到一个文件,然后打开该文件,最好使用更好的文件比记事本更像 Notepad++。

findstr /c:"INVITE sip:" *5656*.dat > results.txt