Skip to content

Instantly share code, notes, and snippets.

@bonobo78
Created December 1, 2017 18:05
Show Gist options
  • Save bonobo78/09b2d33736413df1e3724484f7771cab to your computer and use it in GitHub Desktop.
Save bonobo78/09b2d33736413df1e3724484f7771cab to your computer and use it in GitHub Desktop.
filter ColorPattern( [string]$Pattern, [ConsoleColor]$Color, [switch]$SimpleMatch ) {
if( $SimpleMatch ) { $Pattern = [regex]::Escape( $Pattern ) }
$split = $_ -split $Pattern
$found = [regex]::Matches( $_, $Pattern, 'IgnoreCase' )
for( $i = 0; $i -lt $split.Count; ++$i ) {
Write-Host $split[$i] -NoNewline
Write-Host $found[$i] -NoNewline -ForegroundColor $Color
}
Write-Host
}
Select-String -Path 'Z:\PROJET\RM3\RC1\logRC1.txt' -Pattern '^ORA-' -Context 10,0 | ColorPattern 'ORA-\w*' 'Red'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment