Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How convert Date variable format in bash

I have bash variable named date_export that have 2021-09-22 as a value.
I want assign it to other bash variable named DATE_EXPORT but having other format 20210922
I tried :

DATE_EXPORT=$(date -d ${date_export} + '%Y%m%d')

But, it does not work, any help, please

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The output format is a single word starting with +, not two separate arguments + and the format.

DATE_EXPORT=$(date -d "$date_export" +"%Y%m%d")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading