skip to Main Content

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


  1. 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".

    Login or Signup to reply.
  2. 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]+"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search