‘grep’ in PowerShell 1.0

Question:

I want to find files containing the word “navbar” anywhere in files. I can do this using Mac’s grep command like this:

What’s its equivalent in PowerShell 1.0?

Answer:


It’s a native command but should work well enough.

PowerShell 1.0 itself is a little tricky, as Select-String (the direct equivalent) only exists since 2.0, I think. So you’d have to make do with something like:

Short version:

This is quite literally:

  1. Find all files recursively (the -R part).
  2. Read each file and print matching lines with their file name.

Source:

‘grep’ in PowerShell 1.0 by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply