Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows Powershell中按空格分割模式输出_Windows_Powershell_Split - Fatal编程技术网

Windows Powershell中按空格分割模式输出

Windows Powershell中按空格分割模式输出,windows,powershell,split,Windows,Powershell,Split,我需要提取匹配模式后返回的字符串的第三列。 它还需要是一个单一的班轮 文件包含如下数据: f5834eab44ff bfd0bc8498d8 1557718920 dc8087c38a0d a72e89879030 1557691221 e6d7aaf6d76b caf6cd0ef68c 1557543565 现在它匹配模式并返回行。 但是我不能让它在空格上拆分,这样我就可以得到第三列(索引2) select string-Path$hashlistfile-Pattern'dc8087c38

我需要提取匹配模式后返回的字符串的第三列。 它还需要是一个单一的班轮

文件包含如下数据:

f5834eab44ff bfd0bc8498d8 1557718920
dc8087c38a0d a72e89879030 1557691221
e6d7aaf6d76b caf6cd0ef68c 1557543565
现在它匹配模式并返回行。 但是我不能让它在空格上拆分,这样我就可以得到第三列(索引2)

select string-Path$hashlistfile-Pattern'dc8087c38a0d')|$10;.Split(“”|$2]
输出应为:

1557691221

您可以从由
Select String
生成的输出对象中获取
Line
属性,将其拆分,然后直接索引到
String.split()的结果中:


您可以从由
Select String
生成的输出对象中获取
Line
属性,将其拆分,然后直接索引到
String.split()的结果中:


只能在具有脚本块选项“{}”的cmdlet中使用“$\”。选择字符串返回MatchInfo对象

(select-string dc8087c38a0d $hashlistfile).gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    MatchInfo                                System.Object
拆分操作符似乎更容易处理它。在您的示例中,模式后面有一个额外的括号“)”

select-string dc8087c38a0d $hashlistfile | foreach { -split $_ | select -index 2 }

1557691221

只能在具有脚本块选项“{}”的cmdlet中使用“$\”。选择字符串返回MatchInfo对象

(select-string dc8087c38a0d $hashlistfile).gettype()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     False    MatchInfo                                System.Object
拆分操作符似乎更容易处理它。在您的示例中,模式后面有一个额外的括号“)”

select-string dc8087c38a0d $hashlistfile | foreach { -split $_ | select -index 2 }

1557691221

@elcool您还缺少每个对象的
ForEach
<代码>…|$。Split()的语法无效。@elcool您还缺少ForEach对象的
<代码>…|$。Split()
是无效语法。