按照关键词查询命令:
PowerShell 7.6.4 PS C:\Users\gao> Select-String -Path (Get-PSReadLineOption).HistorySavePath -Pattern "serve.py" AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:266:python3 tools/serve.pyhttp://localhost:8765/#/graph AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:268:python3 tools/serve.pyhttp://localhost:8765/#/graph AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:269:uv python3 tools/serve.pyhttp://localhost:8765/#/graph AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:270:uv run python .\tools\serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:273:uv run python .\tools\serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:284:uv run python .\tools\serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:304:uv run python .\tools\serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:338:uv run python .\tools\serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:342:uv run python serve.py AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:368:Set-Location -LiteralPath 'C:/Users/gao/.codex/worktrees/cdf5/A utoSci/.'; .\.venv\Scripts\python.exe tools\serve.py --port 8877 AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:370:Set-Location -LiteralPath 'C:/Users/gao/.codex/worktrees/cdf5/A utoSci/.'; .\.venv\Scripts\python.exe tools\serve.py --port 8877 AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:371:Set-Location -LiteralPath 'C:/Users/gao/.codex/worktrees/0909/A utoSci/.'; .\.venv\Scripts\python.exe tools\serve.py --port 8877 AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:373:Set-Location -LiteralPath 'C:/Users/gao/.codex/worktrees/0909/A utoSci/.'; .\.venv\Scripts\python.exe tools\serve.py --port 8877 AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:438:python3 tools/serve.pyhttp://localhost:8765/#/graph AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt:439:Select-String -Path (Get-PSReadLineOption).HistorySavePath -Pat tern "serve.py" PS C:\Users\gao>
查询从某行开始的命令:
PS C:\Users\gao> $h=(Get-PSReadLineOption).HistorySavePath
PS C:\Users\gao> $i=0
PS C:\Users\gao> Get-Content $h | ForEach-Object {
>> $i++
>> if($i -ge 237 -and $i -le 310){
>> "{0}: {1}" -f $i,$_
>> }
>> }