I'm running an online store where I can put a variable versiontag to includes JS and CSS as a cachebuster. I. e.
styles.css?v2018_01
Wherein the 2018_01
is the version tag. Now I also have a CLI tool that makes it quick to set like so
mr config:set 'design/head/meta_version_tag' [insert_my_var_here]
And what I want to do is create a Bash alias that sets the variable to the Unix timestamp whenever it is run. I know I can get the Unix timestamp with date +%s
.
So I would make an alias like this:
mr config:set 'design/head/meta_version_tag' date +%s
But the CLI interprets the date +%s
as a string, rather than getting its output first.
So what I need is an output like this:
mr config:set 'design/head/meta_version_tag' 1519747390
And so my question is; how can I get the output of the unix datestamp in my alias?
Provided you use
bash
you can use Command Substitution:This will first run
date +%s
in a subshell and include the output as a string, seeman bash
under EXPANSION/Command Substitution:There's no need to quote the command substitution (like you would normally do) in this case, as the output of
date +%s
doesn't have any whitespaces.How about
Or,