1.常用的内部命令有:
echo;
eval;
读入参数args,并将它们组合成一个新的命令,然后执行。
exec;
export
readonly;
read;
shift;{
[[email protected] ~]# echo $#
3
[[email protected] ~]# echo $1
I am
[[email protected] ~]# shift
[[email protected] ~]# echo $1
handsome
[[email protected] ~]# shift
[[email protected] ~]# echo $1
boy
[[email protected] ~]#}
wait;
exit和点(.)
2.#号的妙用
[[email protected] ~]# echo $PWD
/root
[[email protected] ~]# echo ${#PWD} #显示参数的个数
5
[[email protected] ~]# echo $PWD|wc -m
6
[[email protected] ~]# echo ${PWD:2} #删除前两个
oot
[[email protected] ~]# echo $PWD|cut -c3-5
oot
[[email protected] ~]# echo ${PWD:2:2} #从第三个取共取两个
oo
[[email protected] ~]# echo ${PWD#/ro} #删除“/ro”
ot
[[email protected] ~]# echo ${PWD#/ro} #最短
ot
[[email protected] ~]# echo ${PWD##/ro} #最长
ot
[[email protected] ~]# echo ${PWD%/ro}
/root
[[email protected] ~]# echo ${PWD%ot}
/ro
[[email protected] ~]# echo ${PWD%%ot}
/ro
[[email protected] ~]#
[[email protected] ~]# OLDBOY="I am oldboy"
[[email protected] ~]# echo ${#OLDBOY}
11
[[email protected] ~]# echo ${OLDBOY}|wc -m
12
[[email protected] ~]# echo ${OLDBOY:2}
am oldboy
[[email protected] ~]# echo ${OLDBOY}|cut -c 3-11
am oldboy
[[email protected] ~]# echo ${OLDBOY:2:2}
am
[[email protected] ~]# echo ${OLDBOY#I am}
oldboy
[[email protected] ~]# echo ${OLDBOY##I am}
oldboy
[[email protected] ~]# echo ${OLDBOY%boy}
I am old
[[email protected] ~]# echo ${OLDBOY/I am/You are}
You are oldboy
[[email protected] ~]# echo ${OLDBOY/#oldboy/girl}
girl,and I am handsome oldboy
[[email protected] ~]# echo ${OLDBOY/%oldboy/girl}
oldboy,and I am handsome girl
[[email protected] ~]#
原文地址:http://blog.51cto.com/12040328/2307147