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

Puput avatar
By Puput
at 2011-08-16T23:26

Table of Contents

dear 各位

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

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

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

--
Tags: Linux

All Comments

Ivy avatar
By Ivy
at 2011-08-17T18:26
我用 $result == "" 沒有問題啊??
Ula avatar
By Ula
at 2011-08-20T20:06
grep -q "i=0" input && RET=0 || RET=1 ;
if test RET = 0 ; then ...; else ...; fi
Erin avatar
By Erin
at 2011-08-24T15:09
echo $SHELL; 確認一下你是否在使用bash 你原本的應該也ok
Skylar Davis avatar
By Skylar Davis
at 2011-08-28T05:04
if [ "$result" == "" ] ?

ubuntu還原光碟大量佈署問題

Yedda avatar
By Yedda
at 2011-08-16T17:48
請問一下版上的大家 用還原光碟來大量佈署作業環境 這樣所這定的電腦名稱都會一樣 會不會發生衝突呢? 是不是可以用oem-config-remaster 來解決這個問題? 剛接觸linux的新手 煩請各位替小弟解惑了 - ...

Nao robot安裝環境

Victoria avatar
By Victoria
at 2011-08-16T15:06
不知道版上有沒有先進在玩Nao robot, 小弟在linux安裝Nao所需的環境遇到了一些問題。 在make all的過程中出現錯誤:make :zbuildgen: Command not found 有沒有哪位高手可以指點一下小弟 感謝!!! - ...

可以推薦我 embedded Linux C語言的書嗎?

Edward Lewis avatar
By Edward Lewis
at 2011-08-16T14:49
可以請板上大大 推薦 新手 入門的嵌入式 Linux C語言的書嗎? 不知道哪一本 寫得比較清楚 好懂 又適合新手學的~~ 謝謝大家!!! - ...

Sendmail無法收信 可以寄信

Rosalind avatar
By Rosalind
at 2011-08-16T13:06
各位好: 使用sendmail 目前可以順利將信件寄出 但無法收信 120.0.0.1 已經改成 0.0.0.0 想請教我哪個環節忽略到了? 謝謝! - ...

在pcmanx上用輸入法

Kristin avatar
By Kristin
at 2011-08-16T10:39
我的中文輸入法是gcin 我發現我在用pcmanx的時候 我只能使用兩種輸入法 就eng跟我default的中文輸入-andgt;嘸蝦米 (用ctrl+space換) 我還有其他的注音跟日文輸入就都切不到 (ctrl+shift 都沒反應) 但在一般的情況下我輸入法是正常的 想請問這是我pcman還要設定 ...