select-string语句的一些特点 2


比较下列两个命令的不同输出,就可以发现其中的亮点,第一条命令比linux的bashshell还要方便,对应的linux的命令为

find ./ -type f -exec grep -H “test” {}  \;

而powershell直接使用select-string就达到了这个效果,不过这个我们不是想要的结果,我们想看当前文件夹下有没有名称包含test关键字的文件,看第二条命令。

PS C:\Users\Administrator> ls . | Select-String "test"

.bash_history:139:md5sum.exe test.exe
.bash_history:140:test.exe


PS C:\Users\Administrator> ls . | select -Property Name | Select-String "test"

@{Name=test.txt}
本文链接: https://www.pstips.net/select-string%e8%af%ad%e5%8f%a5%e7%9a%84%e4%b8%80%e4%ba%9b%e7%89%b9%e7%82%b9.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

回复 Hayes 取消回复

您的电子邮箱地址不会被公开。 必填项已用*标注

2 条评论 “select-string语句的一些特点