本人初学linux运维,在观看oldboy视频教程后,对学习到的知识进行总结,知识内容均出自oldboy视频教程。

#########################################################################

字符子串_第1张图片实例操作:


[root@mode scripts]#  OLDBOY="I am oldboy"

[root@mode scripts]# echo  $OLDBOY

I am oldboy

[root@mode scripts]# echo ${#OLDBOY}

11

[root@mode scripts]# echo ${OLDBOY:2} 

am oldboy

[root@mode scripts]# echo ${OLDBOY:0}

I am oldboy

[root@mode scripts]# echo ${OLDBOY:5}

oldboy

[root@mode scripts]# echo ${OLDBOY:2:5}

am ol

[root@mode scripts]# echo ${OLDBOY#I am}

oldboy

[root@mode scripts]# echo ${OLDBOY##I am}

oldboy

[root@mode scripts]# echo ${OLDBOY%I am}  

I am oldboy

[root@mode scripts]# echo ${OLDBOY/oldboy/tiancao}

I am tiancao

[root@mode scripts]# OLDBOY="oldboy I am oldboy"  

[root@mode scripts]# echo ${OLDBOY/oldboy/tiancao} 

tiancao I am oldboy

[root@mode scripts]# echo ${OLDBOY/%oldboy/tiancao}

oldboy I am tiancao