-------------------------------------------------------------------------------------------
内建命令,即bash内置的命令
#!/bin/bash
cd()
{
echo 'ok'
}
cd
echo 'now buitin'
builtin cd
-------------------------------------------------------------------------------------------
echo ${UID}_
It is safe to omit the curly brackets ({}) if the variable name is followed by a character
that isn't a letter, digit, or underscore.
-------------------------------------------------------------------------------------------
排序命令:将当前目录按从大到小排序
du -s * | sort -nr
-------------------------------------------------------------------------------------------
ls命令:
ls -1:很重要,这个数字1,看下面的实用例子
CLASSPATH=`ls -1 $WAD_HOME/shared/lib/*.jar|/usr/bin/tr '\n' ':'`$CLASSPATH; export CLASSPATH
-------------------------------------------------------------------------------------------
AIC2 ftp1204/.dd> cat book5.sh
#!/bin/bash
####这仅仅是在脚本中改变!!!###
cd ../..
echo `ls -l`
ls -S:大小排序
-------------------------------------------------------------------------------------------
yes --help
用法:yes [字符串]...
或:yes 选项
重复输出一行指定的字符串,或者重复输出"y"。
--help 显示此帮助信息并退出
--version 显示版本信息并退出
-------------------------------------------------------------------------------------------
select 语法 :
select 表达式是一种bash的扩展应用,尤其擅长于交互式使用。用户可以从一组不同的值中进行选择。
经常与case使用
#!/bin/bash
#设置提示信息,PS3就是这个作用
PS3="choose your favorate food:"
select i in "apple" "orange" "banana"
do
case $i in
"apple")
echo "your choosed apple"
;;
"orange")
echo "you choosed orange"
;;
"banana")
echo "you choosed banana"
;;
*)
echo "you have other choice"
esac
#必须要有退出语句
break;
done
-------------------------------------------------------------------------------------------
########下面这种方式是等价的##########
ftp1204@AIC2:~/.dd> echo 'abc' | sed -e 's/a/A/g'
Abc
ftp1204@AIC2:~/.dd> echo 'abc' | sed -e 's:a:A:g'
Abc
-------------------------------------------------------------------------------------------