#!/bin/bash version=$(awk '/version "[0-9]/ { sub(/[^"]*"/,"") ; sub(/".*$/,""); print $0 } ' build.gradle) echo version extract from build.gradle '-->' $version if [ $# -gt 0 ]; then time=$1 else time=$(date "+%Y-%m-%d") fi echo time is $time cd ./docker/ awk ' {gsub(/version=\".*\"/,"version=\"'$version'\""); print $0; } ' Dockerfile >Dockerfile.2 awk ' {gsub(/release-date=\".*\"/,"release-date=\"'$time'\""); print $0; } ' Dockerfile.2 >Dockerfile rm Dockerfile.2