判斷文字檔是否出現 "i=0" 字串 - Linux

Table of Contents

dear 各位

我想寫 bash shell 判斷文字檔是否包含 "i=0" 這個字串
我用 result=`grep "i=0" text.txt`
再判斷 if [$result==""]

因為$result裡包含 "="
我這樣寫會有問題

請問怎麼做比較對呢?
謝謝

--

All Comments

Ivy avatarIvy2011-08-17
我用 $result == "" 沒有問題啊??
Ula avatarUla2011-08-20
grep -q "i=0" input && RET=0 || RET=1 ;
if test RET = 0 ; then ...; else ...; fi
Erin avatarErin2011-08-24
echo $SHELL; 確認一下你是否在使用bash 你原本的應該也ok
Skylar Davis avatarSkylar Davis2011-08-28
if [ "$result" == "" ] ?