I have been trying to replace '{{date}}' with a current date stamp in OSX command line. I have been using the following:
sed -i -e 's/{{date}}/`date`/g' mhp.xml
Does anyone know why it ends up putting
`date`
instead of the actual date?
When I try
date=`date`
echo $date
it works... and shows the current date. Any ideas?
sed
script rather than double-quotes. text inside single-quotes is treated as a fixed string literal. Text inside double-quotes is interpolated by the shell, with variable expansions, command substitution (like$(date)
), etc applied. Both forms are useful, sometimes you want string literals, sometimes you want interpolation, sometimes you want both (which requires careful use of quoting and escaping). – cas Mar 25 '16 at 03:29