我有很多大文本文件。 我正在(在cmd.exe中)search其中的值列表,如下所示:
findstr /i /n /g:strings.txt 1\*.* >results.txt
其中strings.txt是我正在查找的所有值的文件,1是我的所有文本文件所在的文件夹。
前面和后面的string中有有价值的信息,我可以用findstrfind。 你能帮我写一个脚本,在每个比赛的results.txt中有三行吗?
电源shell。 具体来说, Select-String Cmdlet的-Context参数将为您提供围绕选定文本的上下文。
PS C:\Users\ryan> gc .\temp.txt 1 2 3 4 5 6 7 8 9 10 PS C:\Users\ryan> gc .\temp.txt | Select-String '4' -Context 3 1 2 3 > 4 5 6 7