Home > Software engineering >  How to delete a file with string.numbers.string format by passing a command in Airflow
How to delete a file with string.numbers.string format by passing a command in Airflow

Time:01-09

This is the file format I have ABD.123244.trig , when I try to remove the file in the terminal I used rm -f ABD. ([0-9]).trig, but when I use the same thru Airflow scheduler, it throwserror unexpected token '('

please help

This command rm -f ABD. ([0-9]).trig doesn't work while passing it thru Airflow scheduler. it throws error unexpected token '('

CodePudding user response:

Airflow bash operator runs the bash command with:

bash -c "<your bash command>"

To use an extended globbing pattern in bash, you have to enable the extglob shell option. You can try:

BashOperator(task_id="bash_task", bash_command="shopt -s extglob\n rm -f ABD. ([0-9]).trig")

CodePudding user response:

The is not a special character in bash, therefore, your expression (...) does not make any sense. Neither does . .

You are thinking regular expressions instead of gobbing patterns.

Try this:

echo ABD.[0-9]*

and the whole command would be:

rm -f ABD.[0-9]*.trig
  • Related