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.
2
Answers
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"
.You’re trying to use perl regexpr (PCRE) :
On debian, the
-E
implies Extended Regexprs (ERE):