shell变量设置
shell变量设置
1.获取变量的方法
echo $HOME
echo ${HOME}
echo ${vbird}
# /home/vbird/testing/testing.x.sh
2.在 变量中,从最前面开始比较,若开头为/,则删除两个/之间的所有数据,即/*/
echo ${vbird##/*/}
testing.x.sh ==>删除了/home/vbird/testing/
echo ${vbird#/*/}
vbird/testing/testing.x.sh ==>删除了/home/
##表示取最长的,#表示取最短的删除
3.在 变量中,从后面开始删除
echo ${vbird%%/*/}
/home/vbird/testing/testing.x.sh ==>都没删除
echo ${vbird%%/*}
==>全被删除了
echo ${vbird%/*}
/home/vbird/testing ==>只删除了/testing.x.sh
%%表示取最长的,%表示取最短的删除
4.将vbird变量中的testing替换成test
echo ${vbird/testing/test}
/home/vbird/test/testing.x.sh
echo ${vbird//testing/test}
/home/vbird/test/test.x.sh
//表示替换全部字符串。/表示仅替换第一个字符串
相关推荐
<?php. if (!empty($_POST)) {. $data1 = $_POST["data1"];$data2 = $_POST["data2"];$fuhao = $_POST["fuh