我有一个包含数据的庞大安装这样的文件:如何将线下划线的模式匹配后
______________________________________________________________________
. 1-9/16 TCS DRILL
. CUT = +2.685/O/A = -2.685
. +2.685/ -2.685
. +3.935/ -3.935
______________________________________________________________________
. 1-11/32 TCS DRILL
. CUT = +0.9/O/A = -3.237
. +0.9/ -3.237
. +0.9/ -4.487
___________________________________________________________________
. 1-11/32 TCS DRILL
. CUT = +5.699/O/A = -5.699
__________________________________________________________________
. 1-1/8 TCS DRILL
. CUT = +1.553/O/A = -1.553
. +2.338/ -2.338
. +2.513/ -2.513
我需要做的就是抓住文本的第一行后,每个“_______” (下划线),
1-9/16 TCS钻头
1-11/32 TCS钻头
1-11/32 TCS钻头
.....
如何在PowerShell中使用get-content或get-childitem指定匹配LINE的模式?
,我可以用线条没有任何这些字符“=”的匹配,“+”,“ - ”,但这种模式是不准确的,不工作...
$file = 'C:\test\001.txt'
Get-Childitem $file | select-string -pattern '=','+','-' -notmatch
我用'GET-Childitem $文件进行这方面的工作| select-string -pattern'_'-Context 0,2',但是这个在结果中包含'____',我会试试你的。谢谢 – 2015-03-30 18:25:25
我可以问''''r'n“'是什么意思? r&n? – 2015-03-30 18:28:43
@RootLoop''''r'n“''是回车符和换行符的PowerShell字符。 – Matt 2015-03-30 18:31:28