PowerShell在文件内查找字符串

PowerShell在文件内查找字符串

命令1

1
Get-ChildItem -Path .\ -Recurse | Select-String -Pattern 'Hello' -List | Select Path
  • Get-ChildItem:获取特定目录及其子项;-Recurse递归所有文件、目录、子目录
  • Select-String:在指定文件中查找字符串

命令2

1
ls -r -Path C:\pc | sls 'Hello' | select -u Path
  • ls:类似于Linux系统命令,使用-r参数列举指定位置的目录及子目录
  • sls:是上一个命令里Select-String的别名

总结

Powershell在功能性上非常丰富且优雅,嗯。

作者

Luan Blesson

发布于

2022-09-15

更新于

2023-02-22

许可协议

评论

Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×