如何在script中確定mount有成功 - Linux

Table of Contents

我有一個備份的指令,要在特定的分割區執行,所以第一步要確定mount。

雖然每次上線的的順序可能變掉,我可以用UUID解決這問題,然後我想到
用grep看mount有沒有備份資料夾的文字來確定mount有沒有成功:

test -n `mount|grep --color "on /backup type ext4"`
來看有沒有mount只會得到
-bash: test: 太多引數

這樣,看來test不能這樣玩。

所以我想請問有沒有辦法在script中檢查【特定的分割區mount到特定的位置】?

--
因為「其實呢,這場戰爭結束後,我就要回老家結婚了。」
而死亡的角色,據研究指出,背後的傷勢比前面還嚴重。

民明書房─《死亡FLAG──你不可不知的真實》

--

All Comments

Mary avatarMary2015-05-21
`mount|grep --color "on /backup type ext4"`
Ursula avatarUrsula2015-05-24
這段不是結果對test不是字串...
他會變成test後面的參數
Suhail Hany avatarSuhail Hany2015-05-27
啊....是這樣啊,那我該怎麼辦?
Andy avatarAndy2015-05-31
用return code, "$?"
Carolina Franco avatarCarolina Franco2015-06-01
直接用 if grep ... /proc/mounts; then...; fi
Tristan Cohan avatarTristan Cohan2015-06-03
test -n "`mount|grep --color "on /backup type ext4"`"