2013-11-22 44 views
0

我要驗證一個變種存在,如果是這樣,它必須把一個短語,如:「你好你怎麼樣」到一個變量。回聲到VAR(殼)

我想:

test -e cours_420216 
if [ $? ] 
echo "alrdy there" 
else 
echo "add this into" > cours_420216 
+0

對於bash解決方案,請參閱http:// stack overflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash –

回答

1

在bash變量賦值形式完成:

cours_420216="hello how are you"

echo "add this into" > cours_420216

將創建一個文件,而不是指定一個變量