Skip to content

Instantly share code, notes, and snippets.

@jmreynolds
Last active March 4, 2016 00:28
Show Gist options
  • Save jmreynolds/061043573b276ef12544 to your computer and use it in GitHub Desktop.
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
#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