您的位置:首页 > 运维架构 > Shell

Linux下shell脚本编写:常用命令

2016-11-04 15:54 811 查看
1.创建软连接
comproject=/home/test

#建立软链接
cd $comproject/src/
rm -rf ipsfe
ln -s $ipsfe ipsfe
2.删除文件

rm  $comproject/src -rf
3.拷贝文件
将test1文件拷贝至test2文件下
cp $comproject/test1  $comproject/test2/ -rf
4.执行.sh文件
SZX1000058409:/home/compileprj/autoscript # sh copy.sh FSPV3R2C70
5.特殊文件的处理
若文件名存在空格或者.等特殊字符
则访问该文件时,使用\ \隔开,例如
文件a所在路径为
SZX1000058409:/home/test/1 IP LIB/1.00 Head Files/
则在shell脚本中,该路径书写为:
/home/test/\1\ IP\ LIB\/\1.\0\0\ Head\ Files\/a
5.脚本中设置参数
脚本名称为test.sh
if [ $1 == "root1" ]
then
m=m_1
v=v_1

elif [ $1 == "root2" ]
then
m=m_2
v=v_2

else
echo "This Version is not exist, please check out."
exit 0
fi
在执行脚本时则为
./test.sh root1
./test.sh root2
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux cp