Board logo

标题: 代码执行结果不一样 [打印本页]

作者: xiaofei120     时间: 2010-5-19 18:39    标题: 代码执行结果不一样

为什么这两个代码执行的结果不一样?

@echo off
type c:\121.txt >1.txt
find "电脑" "C:\Documents and Settings\Administrator\桌面\1.txt" >nul
if "%ERRORLEVEL%"=="0" (
echo 找到电脑二字) else (
echo 找不到电脑二字。)
pause



@echo off
type c:\121.txt | find "电脑"
if "%ERRORLEVEL%"=="0" (
echo 找到电脑二字) else (
echo 找不到电脑二字。)
pause

是不是type c:\121.txt | find "电脑"这句写的有问题?

哪位大哥能解释下.
在下先谢过了兄台了.
作者: Hanyeguxing     时间: 2010-5-19 19:27

@echo off
find "电脑" "c:\121.txt">nul 2>nul&&echo.找到电脑二字||echo.找不到电脑二字。
pause
type干什么啊?

[ Last edited by Hanyeguxing on 2010-5-19 at 19:29 ]