Question: I am using BashOperator to decompress the .gz file in Airflow.

gzip -d archive\_name.csv.gz

So the gzip command replaces the original .gz file with the decompressed archive\_name.csv file

My task in Airflow

```
gzip_file = BashOperator(
    task_id = "gzip_file",
    bash_command = "gzip -d archive_name.csv.gz",
    dag=dag
)

```

Now I need to know the filename in other task in Airflow, so I want that the task gzip\_file should push the filename using xcom so that my other task can pull the filename and use it. How can I do that?

Answer: 
Assuming you are running the latest version of Ariflow, you can set `do_xcom_push`[1] to true and echo your unzipped file as your last command written to stdout, and airflow should do the rest

> 
> If BaseOperator.do\_xcom\_push is True, the last line written to stdout
>  will also be pushed to an XCom when the bash command completes
> 
> 
> 

The downstream task then can use the xcom pull to retrieve that file name [2]

[1]<https://github.com/apache/airflow/blob/45244e38d386f20838a2cc85fbc72edca843a5e1/airflow/operators/bash_operator.py#L34>  

[2]<https://github.com/apache/airflow/blob/master/airflow/example_dags/example_xcom.py>
`BashOperator` has a parameter `xcom_push`. If xcom\_push is True, the last line written to stdout will also be pushed to an XCom when the bash command completes.

So run a bash commands that the last line contains the name of your uncompressed file.

```
gzip_file = BashOperator(
    task_id = "gzip_file",
    bash_command = "gzip -d archive_name.csv.gz | ls archive_name.csv",
    xcom_push=True,
    dag=dag
)

```