Output unix time in alias

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
3
down vote

favorite












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?










share|improve this question



























    up vote
    3
    down vote

    favorite












    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?










    share|improve this question

























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      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?










      share|improve this question















      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?







      bash time alias






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 27 at 17:02









      David Foerster

      26.4k1362106




      26.4k1362106










      asked Feb 27 at 16:04









      Alex Timmer

      15911




      15911




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          6
          down vote



          accepted










          Provided you use bash you can use Command Substitution:



          mr config:set 'design/head/meta_version_tag' $(date +%s)


          This will first run date +%s in a subshell and include the output as a string, see man bash under EXPANSION/Command Substitution:




          Bash performs the expansion by executing command and replacing
          the
          command substitution with the standard output of the command, with any
          trailing newlines deleted.




          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.






          share|improve this answer





























            up vote
            2
            down vote













            How about



            mr config:set 'design/head/meta_version_tag' $(date +%s)


            Or,



            alias dothething='mr config:set "design/head/meta_version_tag" $(date +%s)'





            share|improve this answer




















              Your Answer







              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "89"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              convertImagesToLinks: true,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );













               

              draft saved


              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1010333%2foutput-unix-time-in-alias%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              6
              down vote



              accepted










              Provided you use bash you can use Command Substitution:



              mr config:set 'design/head/meta_version_tag' $(date +%s)


              This will first run date +%s in a subshell and include the output as a string, see man bash under EXPANSION/Command Substitution:




              Bash performs the expansion by executing command and replacing
              the
              command substitution with the standard output of the command, with any
              trailing newlines deleted.




              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.






              share|improve this answer


























                up vote
                6
                down vote



                accepted










                Provided you use bash you can use Command Substitution:



                mr config:set 'design/head/meta_version_tag' $(date +%s)


                This will first run date +%s in a subshell and include the output as a string, see man bash under EXPANSION/Command Substitution:




                Bash performs the expansion by executing command and replacing
                the
                command substitution with the standard output of the command, with any
                trailing newlines deleted.




                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.






                share|improve this answer
























                  up vote
                  6
                  down vote



                  accepted







                  up vote
                  6
                  down vote



                  accepted






                  Provided you use bash you can use Command Substitution:



                  mr config:set 'design/head/meta_version_tag' $(date +%s)


                  This will first run date +%s in a subshell and include the output as a string, see man bash under EXPANSION/Command Substitution:




                  Bash performs the expansion by executing command and replacing
                  the
                  command substitution with the standard output of the command, with any
                  trailing newlines deleted.




                  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.






                  share|improve this answer














                  Provided you use bash you can use Command Substitution:



                  mr config:set 'design/head/meta_version_tag' $(date +%s)


                  This will first run date +%s in a subshell and include the output as a string, see man bash under EXPANSION/Command Substitution:




                  Bash performs the expansion by executing command and replacing
                  the
                  command substitution with the standard output of the command, with any
                  trailing newlines deleted.




                  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.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 27 at 16:21

























                  answered Feb 27 at 16:08









                  dessert

                  20k55795




                  20k55795






















                      up vote
                      2
                      down vote













                      How about



                      mr config:set 'design/head/meta_version_tag' $(date +%s)


                      Or,



                      alias dothething='mr config:set "design/head/meta_version_tag" $(date +%s)'





                      share|improve this answer
























                        up vote
                        2
                        down vote













                        How about



                        mr config:set 'design/head/meta_version_tag' $(date +%s)


                        Or,



                        alias dothething='mr config:set "design/head/meta_version_tag" $(date +%s)'





                        share|improve this answer






















                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          How about



                          mr config:set 'design/head/meta_version_tag' $(date +%s)


                          Or,



                          alias dothething='mr config:set "design/head/meta_version_tag" $(date +%s)'





                          share|improve this answer












                          How about



                          mr config:set 'design/head/meta_version_tag' $(date +%s)


                          Or,



                          alias dothething='mr config:set "design/head/meta_version_tag" $(date +%s)'






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 27 at 16:09









                          waltinator

                          20.7k74168




                          20.7k74168



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1010333%2foutput-unix-time-in-alias%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              pylint3 and pip3 broken

                              Missing snmpget and snmpwalk

                              How to enroll fingerprints to Ubuntu 17.10 with VFS491