2

I am new to powershell.

I have been looking for how to code look for a certain phrase/text in the folder

and show output each file name.

I code this looks for a certain phrase which in this case, "v_lfy" in A file

select-string -path "C:\Users\kiki\Desktop\copy\allocation - Copy.prc"
-pattern "v_lfy"

but I would like to look for "v_lfy" from many files in the folder.

and output shows the each file name like C:\Users\kiki\Desktop\copy\allocation - Copy.prc

How should I code?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
FZK
  • 23
  • 2

1 Answers1

3

You can use Get-ChildItem to discover the files in the folder, then pipe them to Select-String

Get-ChildItem 'C:\Users\kiki\Desktop\copy' -Filter *.prc |Select-String -Pattern "v_lfy"
Mathias R. Jessen
  • 157,619
  • 12
  • 148
  • 206
  • 1
    and -Recurse if you need to run through child folders. – dfundako Nov 11 '16 at 15:29
  • What if there is other files like "money.sql" or "money.gnt" in the folder, so I would like to add code *.sql, *gnt, how can I code like that? – FZK Nov 11 '16 at 16:33