by failing time after time, I finally master the tricks of writing Linux shell, the most classical examples were the usage of 'if' sentence in shell language. Here are the tips and samples:
semantics:
if [ conditions ]; then
command
fi
such as test the existance of a file, we use:
if [ -f "filename" ]; then
echo yes
fi
but you should be caution that between symbol '[' and '-f' must insert a space, if not the system will parse '[-f' as a single command, and print error msg: [-f: command not found
besides, if you comparing two variables by using symbol '=' or '==', you have to insert empty space in both sides, or the test will failed.