From 1401302301ed6ce90cd4e878acbacedbb4dd460d Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Wed, 14 May 2025 07:58:51 +0200 Subject: [PATCH] Updated search-files.ps1 --- scripts/search-files.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/search-files.ps1 b/scripts/search-files.ps1 index 5f674a24..527719ab 100755 --- a/scripts/search-files.ps1 +++ b/scripts/search-files.ps1 @@ -23,14 +23,15 @@ param([string]$textPattern = "", [string]$filePattern = "") function ListLocations { param([string]$textPattern, [string]$filePattern) + $files = Get-Item $filePattern $list = Select-String -path $filePattern -pattern "$textPattern" foreach($item in $list) { New-Object PSObject -Property @{ 'FILE'="$($item.Path)"; 'LINE'="$($item.LineNumber):$($item.Line)" } } - "✅ Found $($list.Count) lines containing '$textPattern' in $filePattern." + "✅ Found $($list.Count) lines in $($files.Count) files containing '$textPattern'." } try { - if ($textPattern -eq "" ) { $textPattern = Read-Host "Enter the text pattern, e.g. 'UFO'" } - if ($filePattern -eq "" ) { $filePattern = Read-Host "Enter the file pattern, e.g. '*.ps1'" } + if ($textPattern -eq "" ) { $textPattern = Read-Host "Enter the text pattern (e.g. ALIEN)" } + if ($filePattern -eq "" ) { $filePattern = Read-Host "Enter the file pattern (e.g. *.txt)" } ListLocations $textPattern $filePattern | Format-Table -property FILE,LINE -autoSize exit 0 # success