Reputation: 424
I have a Dockerfile and would like to grep AIRFLOW_VERSION from it:
Dockerfile
ARG AIRFLOW_VERSION="2.1.0" <---- This one
This command works fine on my local machine (OSX):
export AIRFLOW_VERSION=$(grep "ARG AIRFLOW_VERSION=" /Dockerfile | grep -Eo "\d\.\d\.\d")
echo $AIRFLOW_VERSION
2.1.0
But when I run it on Debian machine (Gitlab Runner), it founds nothing. Pulled the image of the runner locally and double-checked, nothing was found. The file is there, no issue with missing on misplaced file.
Upvotes: 0
Views: 76
Reputation: 5041
You're trying to use perl regexpr (PCRE) :
echo AIRFLOW_VERSION="2.1.0" | grep -Po "\d\.\d\.\d"
On debian, the -E
implies Extended Regexprs (ERE):
echo AIRFLOW_VERSION="2.1.0" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+"
Upvotes: 1
Reputation: 1910
I believe that the issue is related to different version of grep
implementation: GNU for Debian and BSD for Mac OS.
Try to replace -E
with -P
like: grep -Po "\d\.\d\.\d"
.
Upvotes: 1