Within a larger bash script I use a line with a perl command to substitute a time stamp in a text file with the current date and time. I use the following the lines:
perlcmd="perl -i -pe 's/2005-03-31T19:13:30/$(date +"%Y-%m-%dT%H:%M:%S")/' ./file.txt"
echo $perlcmd
$perlcmd
The echo command shows me that the perl command is okay, its output is:
perl -i -pe 's/2005-03-31T19:13:30/2017-12-21T11:33:44/' ./file.txt
The time stamp, however, is not substituted. When I paste the echoed line to the command line it is executed properly and the time stamp is substituted. How to I have to change the code in the bash script to make it work?