Find file: Difference between revisions

From AWVVO
Jump to navigationJump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
== Powershell ==
== Powershell ==
<syntaxhighlight lang="bash" copy>
<syntaxhighlight lang="PowerShell" copy>
  try { Get-ChildItem -Path "C:\" -Filter "myfile.txt" -Recurse -ErrorAction Stop } catch { }
  try { Get-ChildItem -Path "C:\" -Filter "myfile.txt" -Recurse -ErrorAction Stop } catch { }
</syntaxhighlight>
</syntaxhighlight>


== Powershell find string in file ==
== Powershell find string in file ==
<syntaxhighlight lang="bash" copy line highlight="0">
<syntaxhighlight lang="PowerShell" copy line highlight="0">
Get-ChildItem -Path "path\to\search" -Filter "*.js" -Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "your-search-string" -ErrorAction SilentlyContinue | Format-List
Get-ChildItem -Path "path\to\search" -Filter "*.js" -Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "your-search-string" -ErrorAction SilentlyContinue | Format-List
</syntaxhighlight>
</syntaxhighlight>

Latest revision as of 11:36, 6 April 2025

Powershell

 try { Get-ChildItem -Path "C:\" -Filter "myfile.txt" -Recurse -ErrorAction Stop } catch { }

Powershell find string in file

Get-ChildItem -Path "path\to\search" -Filter "*.js" -Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "your-search-string" -ErrorAction SilentlyContinue | Format-List