Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- .SYNOPSIS
- Grep-like search command
- .DESCRIPTION
- This script works like 'grep -f FILE'.
- .PARAMETER Directory
- target directory (default '.')
- .PARAMETER Keyword
- path name to keyword file (default 'keyword.txt')
- #>
- Param (
- [parameter(Mandatory=$false)][String]$Directory='.'
- , [parameter(Mandatory=$false)][String]$Keyword='keyword.txt'
- )
- $Keywords = Get-Content $Keyword
- Get-ChildItem $Directory -Filter '*.csv' | ForEach-Object {
- $File = $_.Name
- Write-Output $File
- $Keywords | ForEach-Object {
- $Count = (Select-String -Pattern $_ -Path $File | Measure-Object).Count
- if ($Count -gt 0) {
- Write-Output ${_}:$Count
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement