Last active
March 4, 2016 00:28
-
-
Save jmreynolds/061043573b276ef12544 to your computer and use it in GitHub Desktop.
I'm forever needing to search through files for various strings and either pipe them to the command line or send them to a file.
Here's a couple commands to help out. From http://stackoverflow.com/questions/8153750/how-to-search-a-string-in-multiple-files-and-return-the-names-of-files-in-powers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#push direct to the command line. | |
Get-ChildItem -recurse | Select-String -pattern "dummy" | group path | select name | |
# a little more setup, but pushes out to a txt file | |
# Nice for searching for specific errors in a bunch of log files. | |
$logdir = "SOMEDIR" | |
$csvpath = "SOMEPATH" | |
gci $logdir -rec *.txt | gc | select-string $pattern | add-content $csvpath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment