1.判断变量是否为空
[ -z "$VAR" ]&&echo “NULL”||echo "NOT NULL"
2.判断变量是否存在
[ -e "$VAR" ]&& echo "EXIST"||echo "NOT EXIST"
3. 使用双引号和单引号定义变量内容的区别
1) var="lang is $LANG"&&echo $var, 返回lang is en_US
2) var='lang is $LANG'&&echo $var,返回lang is $LANG
4. 编写一个可接收stdin的脚本
#!/bin/bash
read input
echo $input| filter1| filter2….
转载于:https://blog.51cto.com/dchampion/846875