In Python
, if I have a to create a string with date as suffix, we can do some thing like this:
date = get_todays_date()
name = "automation_results_{}'.format(date)
What is the equivalent of .format
in shell/bash
scripting language?
In Python
, if I have a to create a string with date as suffix, we can do some thing like this:
date = get_todays_date()
name = "automation_results_{}'.format(date)
What is the equivalent of .format
in shell/bash
scripting language?
In bash you can get a date string by invoking date
:
name="automation_results_"$(date +%Y_%m_%d)
with the different options for the format string you can get any date format you prefer.
As @cdarke commented, if you have a recent version of bash
you can also do the faster:
name=$(printf "automation_results_%(%Y_%m_%d)T")