I'm trying to create a bash script where I can replace a date in a filename with the current date, however, I'm not being able to do so.
Here's what I have so far:
#!/bin/bash
my_file="FILENAME_20170410235908_GTT_DEV_20170410235400_20170410235408_XX_YY.nc"
my_date=`date "+%Y%m%d"`
echo "$my_file" | sed 's/([0-9]{12})/"${my_date}"/g'
I'm currently getting this:
FILENAME_"${my_date}"08_GTT_DEV_"${my_date}"00_"${my_date}"08_XX_YY.nc
Howerver, this is what I'd like to have:
FILENAME_2019070135908_GTT_DEV_20190701235400_20190701235408_XX_YY.nc
How can I achieve this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…