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

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的命令[一脸懵逼]

 

 

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

 

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

利用元字符查找。
\<xyz    字位置: 字的开始
xyz\>    字位置: 字的结束
  1. @echo off
  2. findstr "\<1080\> \<443\> \<80\>" 1.txt>>2.txt
  3. echo 处理完成,按任意键退出
  4. pause>nul
posted @ 2019-04-15 02:20  蓝天上的云℡  阅读(3367)  评论(0编辑  收藏  举报