本文主要是介绍Shell多行注释写法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
假设我们想注释多行代码在bash中,我们可以这么写:
:<<'
这里写注释内容
'
比如,没注释前,我的脚步是这样的:
#!/bin/bash
export PATH=~/gogoal_platform/ggopenapi:~/play-1.2.7:$PATH
echo "构建后的路径pwd:"`pwd`
whoami
cd /home/developer/gogoal_platform/ggopenapi/api/ggservice/
cur=$(pwd)
currday=`date +%Y%m%d`
# 打包的文件名
fileName="ggservice-dataservice"backup=`find . -name "${fileName}-*" | xargs ls -t | head -n 3|xargs|sed "s/.\///g"|xargs|sed "s/ /\\\\\\|/g"`
echo "保留最近三个备份包:" \"$backup\"
echo "删除的备份包:"`ls | grep "${fileName}-.*" | grep -v $backup`
#删除ggservice的备份包
rm -rf `ls | grep "${fileName}-.*" | grep -v $backup | xargs | sed "s/ / /g"`#创建最新的备份包
gogalwebfile=${cur}/${fileName}-$currday
if [ ! -f $gogalwebfile ]; then
echo "不存在":$gogalwebfile
cp -r ${fileName}.jar ${fileName}-$currday
ficp /dev/null nohup.out
#nohup ./ggservice.sh
注释后,是这么写的:
:<<'
#!/bin/bash
export PATH=~/gogoal_platform/ggopenapi:~/play-1.2.7:$PATH
echo "构建后的路径pwd:"`pwd`
whoami
cd /home/developer/gogoal_platform/ggopenapi/api/ggservice/
cur=$(pwd)
currday=`date +%Y%m%d`
# 打包的文件名
fileName="ggservice-dataservice"backup=`find . -name "${fileName}-*" | xargs ls -t | head -n 3|xargs|sed "s/.\///g"|xargs|sed "s/ /\\\\\\|/g"`
echo "保留最近三个备份包:" \"$backup\"
echo "删除的备份包:"`ls | grep "${fileName}-.*" | grep -v $backup`
#删除ggservice的备份包
rm -rf `ls | grep "${fileName}-.*" | grep -v $backup | xargs | sed "s/ / /g"`#创建最新的备份包
gogalwebfile=${cur}/${fileName}-$currday
if [ ! -f $gogalwebfile ]; then
echo "不存在":$gogalwebfile
cp -r ${fileName}.jar ${fileName}-$currday
ficp /dev/null nohup.out
#nohup ./ggservice.sh
'
参考地址:
http://www.jb51.net/article/58236.htm
这篇关于Shell多行注释写法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!