no

raining now

go to school and play with code 你.

 

findstr "\<go  code\>"

这样就能匹配输出包含go到code的文本了

看起来丑,其实也就是\斜线加尖括号   (转义而已)

echo "go to school and play with code 你." | findstr "\<go code\>"
结果: "go to school and play with code 你."

但是这样也行,我就懵了

echo "go to school and play with code 你." | findstr "\<code go\>"
"go to school and play with code 你."

 还有这样

echo "go to school and play with code 你." | findstr "\<code\> \<go\>"
"go to school and play with code 你."

而这最后这种情况有个强大的bug,

它有时搭配dir时只输出包含中文的内容,我的是win10预览版,正式版怎么样不清楚,气死我了,难怪windows在命令行领域干不过Linux

出bug的命令[一脸懵逼]

[灯火阑珊] 关于cmd命令里的findstr匹配多个关键词

 

 [灯火阑珊] 关于cmd命令里的findstr匹配多个关键词

所以这玩意到底是怎么用的

 

附上从不知道哪里复制过来的,侵权请联系我

利用元字符查找。
\<xyz    字位置: 字的开始
xyz\>    字位置: 字的结束
  1. @echo off
  2. findstr "\<1080\> \<443\> \<80\>" 1.txt>>2.txt
  3. echo 处理完成,按任意键退出
  4. pause>nul

相关文章:

  • 2021-11-27
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2022-01-24
  • 2021-09-28
  • 2021-11-21
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2021-06-21
  • 2021-11-17
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-12-05
相关资源
相似解决方案