bat脚本简单命令

1.if 判断

(1.1)判断字符串是否为空:

    if "%var1%" == " " ( echo null)
      else(echo not null )

(1.2)判断字符串是否不等于test  

    if not "%var1%" == "test" ( echo not equal)
    else(echo equal )

(1.3)判断文件是否存在

  if exist test1.txt (echo exist file)

(1.4)判断数值是否相等

  if 1 equ 2 (echo equal) else (echo 1 not equal 2)

2.findstr 找到包含指定字符的文件

例子: dir /B |findstr "test"

猜你喜欢

转载自www.cnblogs.com/zndxall/p/9168031.html