Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Windows 外壳中:
echo "foo bar" | find "foo"
成功(即errorlevel = 0)。但是,我想要一个在某些输入文本中找到特定单词时失败的脚本(即 errorlevel <> 0)。有任何想法吗?
一点点诡计就可以模仿你想要的。只有前三行是必需的,其余的只是一个测试。
c:> echo "foo bar" | find "foo" c:> if x%errorlevel%==x0 echo 1 | find "2" c:> if not x%errorlevel%==x0 echo 1 | find "1" >nul 2>nul c:> echo %errorlevel% 1