bash用法参数详细说明,bash常用命令一览表,bash最全使用文档, 使用手册。

check environment variable is defined

# use the string "is not null" operator
if [ -n $MY_ENV_VAR ]; then
    echo "MY_ENV_VAR is defined as $MY_ENV_VAR"
else
    echo "MY_ENV_VAR is not defined."
fi 

check environment variable is not defined

# use the string "is null" operator
if [ -z $MY_ENV_VAR ]; then
    echo "MY_ENV_VAR is not defined."
else
    echo "MY_ENV_VAR is defined as $MY_ENV_VAR"
fi 

check available commands/aliases/etc.

compgen is a built-in bash command that can list all the Linux commands you can run.

loops on the command line

$ for f in `ls -1 /data/playlists/data*`; do  basename $f; done