Added search-files.ps1

This commit is contained in:
Markus Fleschutz
2020-12-29 11:03:53 +00:00
parent ed8618dbae
commit 0fd980ebef
4 changed files with 34 additions and 4 deletions

29
Scripts/search-files.ps1 Executable file
View File

@ -0,0 +1,29 @@
#!/snap/bin/powershell
# Syntax: ./search-files.ps1 [<pattern>] [<path>]
# Description: searches the given pattern in the given files
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0
param([String]$Pattern, [String]$Path)
Set-StrictMode -Version Latest
try {
if ($Pattern -eq "" ) {
$Pattern = read-host "Enter search pattern"
}
if ($Path -eq "" ) {
$Path = read-host "Enter path to files"
}
$List = Select-String -Path $Path -Pattern "$Pattern"
foreach ($Item in $List) {
write-output "$($Item.Path) @$($Item.LineNumber)`t$($Item.Line)"
}
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}

View File

@ -1,7 +1,7 @@
#!/snap/bin/powershell
# Syntax: ./turn-volume-down.ps1 [<percent>]
# Description: turns the volume down (-10% by default)
# Description: turns the audio volume down (-10% by default)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0

View File

@ -1,7 +1,7 @@
#!/snap/bin/powershell
# Syntax: ./turn-volume-up.ps1 [<percent>]
# Description: turns the volume up (+10% by default)
# Description: turns the audio volume up (+10% by default)
# Author: Markus Fleschutz
# Source: github.com/fleschutz/PowerShell
# License: CC0