powershell - Why select-string doesnot receive from pipelining -
i trying parse out patterns file , search files strings group them. here code , error getting
ps d:\shared_with_pai\testing> get-content c:\\events.txt | select-string -pattern $_ * |select-object linenumber,filename|format-table -groupby filename select-string : cannot bind argument parameter 'pattern' because null. @ line:1 char:52 + get-content c:\\events.txt | select-string -pattern <<<< $_ * |select-object linenumber,filename|format-table -groupby filename + categoryinfo : invaliddata: (:) [select-string], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.powershell.commands.selectstrin gcommand
can making mistake?
edit: contents of events.txt like
8,coilevent,networkchange 8,coilevent,malfunction 8,coilevent,conflictwithpc
i searching csv files these lines.
the current object variable $_
isn't populated objects pipeline if use way. @kayasax suggested, need put statement in loop if want work that:
get-content c:\events.txt | % { select-string -pattern $_ * } | ...
however, there's no need read input pipeline in first place. -pattern
accepts string array, can read file patterns in subexpression:
select-string -pattern (get-content 'c:\events.txt') * | ...
Comments
Post a Comment