Can't get $(date +%F) set as environment variable





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







6















I would like to create an environment variable that will output the current date. I have added the following to ~/.pam_environment:



TODAY=$(date +%F)


Apparently, you have to log out after changing ~/.pam_environment. I did that but



echo $TODAY


outputs a blank line.



What am I doing wrong?










share|improve this question































    6















    I would like to create an environment variable that will output the current date. I have added the following to ~/.pam_environment:



    TODAY=$(date +%F)


    Apparently, you have to log out after changing ~/.pam_environment. I did that but



    echo $TODAY


    outputs a blank line.



    What am I doing wrong?










    share|improve this question



























      6












      6








      6








      I would like to create an environment variable that will output the current date. I have added the following to ~/.pam_environment:



      TODAY=$(date +%F)


      Apparently, you have to log out after changing ~/.pam_environment. I did that but



      echo $TODAY


      outputs a blank line.



      What am I doing wrong?










      share|improve this question
















      I would like to create an environment variable that will output the current date. I have added the following to ~/.pam_environment:



      TODAY=$(date +%F)


      Apparently, you have to log out after changing ~/.pam_environment. I did that but



      echo $TODAY


      outputs a blank line.



      What am I doing wrong?







      bash environment-variables






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 3:11









      Pang

      14126




      14126










      asked Apr 24 '13 at 0:55









      Mark McKennaMark McKenna

      3112




      3112






















          3 Answers
          3






          active

          oldest

          votes


















          4














          ~/.pam_environment is not a script file. Use ~/.profile instead:



          export TODAY=$(date +%F)





          share|improve this answer































            2














            You forgot the "quotes" Here is a Cool Link for more examples.



            TODAY= date +"%F"





            share|improve this answer
























            • Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

              – Mark McKenna
              Apr 25 '13 at 1:32








            • 2





              @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

              – Eliah Kagan
              Jan 25 '17 at 11:23





















            0














            $ export DATE=`date +"%F"`
            $ echo $DATE
            2014-05-30





            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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              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%2f284781%2fcant-get-date-f-set-as-environment-variable%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              4














              ~/.pam_environment is not a script file. Use ~/.profile instead:



              export TODAY=$(date +%F)





              share|improve this answer




























                4














                ~/.pam_environment is not a script file. Use ~/.profile instead:



                export TODAY=$(date +%F)





                share|improve this answer


























                  4












                  4








                  4







                  ~/.pam_environment is not a script file. Use ~/.profile instead:



                  export TODAY=$(date +%F)





                  share|improve this answer













                  ~/.pam_environment is not a script file. Use ~/.profile instead:



                  export TODAY=$(date +%F)






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 29 '14 at 17:24









                  Gunnar HjalmarssonGunnar Hjalmarsson

                  19.7k23461




                  19.7k23461

























                      2














                      You forgot the "quotes" Here is a Cool Link for more examples.



                      TODAY= date +"%F"





                      share|improve this answer
























                      • Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                        – Mark McKenna
                        Apr 25 '13 at 1:32








                      • 2





                        @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                        – Eliah Kagan
                        Jan 25 '17 at 11:23


















                      2














                      You forgot the "quotes" Here is a Cool Link for more examples.



                      TODAY= date +"%F"





                      share|improve this answer
























                      • Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                        – Mark McKenna
                        Apr 25 '13 at 1:32








                      • 2





                        @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                        – Eliah Kagan
                        Jan 25 '17 at 11:23
















                      2












                      2








                      2







                      You forgot the "quotes" Here is a Cool Link for more examples.



                      TODAY= date +"%F"





                      share|improve this answer













                      You forgot the "quotes" Here is a Cool Link for more examples.



                      TODAY= date +"%F"






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Apr 24 '13 at 1:16









                      Scott GoodgameScott Goodgame

                      2,359820




                      2,359820













                      • Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                        – Mark McKenna
                        Apr 25 '13 at 1:32








                      • 2





                        @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                        – Eliah Kagan
                        Jan 25 '17 at 11:23





















                      • Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                        – Mark McKenna
                        Apr 25 '13 at 1:32








                      • 2





                        @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                        – Eliah Kagan
                        Jan 25 '17 at 11:23



















                      Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                      – Mark McKenna
                      Apr 25 '13 at 1:32







                      Unfortunately that did not work. I tried experimenting a bit and added the following to ~/.pam_environment: TODAY=date +"%F" TODAYS=$(date +"%F") NOW=$(date +"%m-%d-%Y") None of these are working

                      – Mark McKenna
                      Apr 25 '13 at 1:32






                      2




                      2





                      @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                      – Eliah Kagan
                      Jan 25 '17 at 11:23







                      @ScottGoodgame That's not the problem. It is not generally necessary to quote %, and although the reference you provided follows this style, it does not actually say one has to do so. Try some examples from that page without quotes (e.g., date +%m-%d-%y). It works fine. In addition, TODAY= date +"%F" actually runs date +"%F" with TODAY set to the empty string in its environment.

                      – Eliah Kagan
                      Jan 25 '17 at 11:23













                      0














                      $ export DATE=`date +"%F"`
                      $ echo $DATE
                      2014-05-30





                      share|improve this answer






























                        0














                        $ export DATE=`date +"%F"`
                        $ echo $DATE
                        2014-05-30





                        share|improve this answer




























                          0












                          0








                          0







                          $ export DATE=`date +"%F"`
                          $ echo $DATE
                          2014-05-30





                          share|improve this answer















                          $ export DATE=`date +"%F"`
                          $ echo $DATE
                          2014-05-30






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 29 '14 at 16:42









                          Eric Carvalho

                          42.5k17118148




                          42.5k17118148










                          answered May 29 '14 at 16:23









                          user286563user286563

                          91




                          91






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Ask Ubuntu!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f284781%2fcant-get-date-f-set-as-environment-variable%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              How did Captain America manage to do this?

                              迪纳利

                              南乌拉尔铁路局