0

我正在尝试开发以下unix脚本的批处理等效(Windows)代码:-

i=`grep "ora-error" *.txt|wc -l`
if [ i -gt 0 ]; then
echo "true"
else
echo "false"
fi

尝试使用 "find /c "ora-error" *.txt" 但无法将 o/p 放入变量并将其重定向到 if 条件...

IE。当我使用 "find /c "ora-error" *.txt" 下面是输出

---------- xx.TXT: 0

---------- yy.TXT: 0

---------- zz.TXT: 0

我想计数并将 valur 重定向到 IF 条件。

我需要一个窗口脚本来解决这个问题。

任何机构都可以帮助解决这个问题...

提前致谢..

带着敬意

sree

大佬们想出了一个办法......

find /c "ora-error" *.txt>TEST1.txt
find /c "0" TEST1.TXT>TEST2.TXT
FOR /F "TOKENS=1* DELIMS=:" %%A IN (TEST2.TXT) DO SET a=%%B
set _count=%a%
IF %_count% EQU 4 goto matched
IF not %_count% EQU 4 goto notmatched

:matched
echo we are in equal to 4 loop
pause
exit

:notmatched
echo we are in not equal to 4 loop
pause
exit
4

1 回答 1

0
grep "ora-error" *.txt>/dev/null
if [ $? -eq 0 ]; then
echo "true"
else
echo "false"
fi
于 2012-10-04T12:18:27.593 回答