2013-11-22 34 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

将创建一个文件,而不是指定一个变量