看过网络,但找不到任何有用的东西。我正在尝试创建一个可以删除页面内容的页面。设法进行搜索,可以告诉您.txt文件中是否有单词。我怎么把它放进去?
cls
set /p SEARCH= Please enter what you want to look for?
for /f "Delims=" %%a in (test.txt) do (
set FIND=%%a
)
if %SEARCHS%==%FIND% goto FLIGHT HAS ARRIVED
echo We were not able to find %SEARCH%
pause
goto start
有人知道我应该做什么吗?
谢谢, 亚历
答案 0 :(得分:1)
type file|find "string in lines to remove" /i /v >newfile
可能有所帮助。
set /p reg=text:
{
{1}}
我不知道你想做什么,但如果这没有帮助请详细说明。
答案 1 :(得分:0)
试试这个:
@ECHO OFF &SETLOCAL
set /p "SEARCH= Please enter what you want to look for? "
for /f "Delims=" %%a in ('find "%SEARCH%" test.txt') do set "FOUND=%%a"
if DEFINED FOUND goto FLIGHT_HAS_ARRIVED
echo We were not able to find %SEARCH%
pause
goto start
:FLIGHT_HAS_ARRIVED
ECHO %SEARCH% found: %FOUND%
goto:eof
您不应将cmd命令名称用于变量名称(%FIND%
)。
如果跳转标签包含空格,则跳转标签不会按预期工作:FLIGHT HAS ARRIVED