The grep UNIX command allows you to find lines in files that contain key words or phrases. With this command, it is possible to perform a quick search of a file or directory without having to look at each file via a text editor or the UNIX more command.
To achieve same functionality in PowerShell, we can use Select-String cmdlet as shown below:
dir -Recurse *.* | Select-String -Pattern "Clear" | Select -Unique path
This will list all the files with path that contains “Clear” as string inside it.
Below command line will look for all the patterns available in Pattern.txt and will list the matching files with the path.
dir -Recurse *.* | Select-String -Pattern (Get-Content .\Pattern.txt) | Select -Unique path
–End of Article–