2017年3月13日 星期一

好用的 cmd 指令 (01)

最近在工作上有接觸 cmd 指令
這邊記一下好用的東西
========================================================
if + findstr using
========================================================
findstr "string" file
if errorlevel 1 (
    echo String NOT found...
) else (
    echo String found
)
========================================================
Example for findstr
========================================================
F:\test>findstr /v "black white" blackwhite.txt

red
blue

========================================================
F:\test>findstr "black white" blackwhite.txt

black
white
black white
black and white

========================================================
F:\test>findstr /c:"black white" blackwhite.txt

black white

========================================================
F:\test>findstr "white" blackwhite.txt | findstr "black"

black white
black and white

========================================================
findstr + errorlevel code
========================================================
findstr /C:FFFF info_1.hex
IF ERRORLEVEL 1 goto NOT_MATCH
echo MATCH
goto END

沒有留言:

張貼留言