原本的find命令:
find /apps/Devops/jenkins/workspace/swapping/target/ -name '*swapping*.jar'
错误的命令:
SOURCE_PATH=/apps/Devops/jenkins/workspace
SERVER_NAME=swapping
SOURCE_JAR_PATH=$(find "$SOURCE_PATH/$SERVER_NAME/target/" -name '*$SERVER_NAME*.jar' )
echo $SOURCE_JAR_PATH
正确的命令如下:
SOURCE_PATH=/apps/Devops/jenkins/workspace
SERVER_NAME=swapping
SOURCE_JAR_PATH=$(find "$SOURCE_PATH/$SERVER_NAME/target/" -name "*$SERVER_NAME*.jar" )
echo $SOURCE_JAR_PATH
注意 多个变量在 命令中 使用双引号括起来