shell

1 $@

$@所有参数列表。如"$@"「"」括起来的情况、以"$1" "$2" … "$n"的形式输出所有参数。
$0: Shell本身的文件名
$? :最后运行的命令的结束代码(返回值)

${parameter:-word}
# If parameter is unset or null, the expansion of word is substituted. 
# Otherwise, the value of parameter is substituted.

参考:
http://www.cnblogs.com/fhefh/archive/2011/04/15/2017613.html

2 case

case $number in
1|2|3)
        echo "the number you input is 1~3"
       ;;
4|5|6|7|8|9|10)
        echo "the number you input is 4~10"
        ;;
*)
        echo "error! the number you input isn't 1 to 10"
        ;;
esac

参考:
http://yangdong.blog.51cto.com/2959198/545931

3 if

if 条件
then
 Command
else
 Command
fi 
# -z STRING: the length of STRING is zero,如果后面的string为空
if [ -z "${SPARK_HOME}" ]; then
  source "$(dirname "$0")"/find-spark-home
fi
# if [ -f file ] 如果文件存在
# if [ -d ... ] 如果目录存在
# if [ -n $string ] 如果string 非空(非0),返回1(true)  

参考:
http://www.cnblogs.com/myitm/archive/2012/07/05/2577416.html
http://wiki.jikexueyuan.com/project/linux-command/chap28.html

4 source

.的效果一样

source FileName

作用:在当前bash环境下读取并执行FileName中的命令。

5 set

declare mylove='Visual C++' #定义新环境变量
set -a mylove #设置为环境变量
env | grep mylove #显示环境变量值
-a:标示已修改的变量,以供输出至环境变量。

参考:
http://man.linuxde.net/set

6 << 重定向

重定向

# cmd << delimiter
cat << EOF > output.sh
echo "hello"
echo "world"
EOF

参考:
https://my.oschina.net/u/1032146/blog/146941

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值