How to output the date without a colon using bash command











up vote
0
down vote

favorite












I want to output the following:



command:




date +%T*




01:49:14


But how to display it without the colons.. any ideas? I'm using bash command.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I want to output the following:



    command:




    date +%T*




    01:49:14


    But how to display it without the colons.. any ideas? I'm using bash command.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I want to output the following:



      command:




      date +%T*




      01:49:14


      But how to display it without the colons.. any ideas? I'm using bash command.










      share|improve this question















      I want to output the following:



      command:




      date +%T*




      01:49:14


      But how to display it without the colons.. any ideas? I'm using bash command.







      bash date command






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 20 at 7:09









      RavinderSingh13

      24.8k41437




      24.8k41437










      asked Nov 20 at 7:00









      Warsiders23

      132




      132
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          When I do man date I got:




          %T time; same as %H:%M:%S




          Then why don't we do which will give same output as %T option in date rather than using %T with external or bash tools to get results in different forms:



          date +"%H-%M-%S"
          OR
          date +"%H/%M/%S"
          OR
          date +%H%M%S ##Without any output delimiter





          share|improve this answer



















          • 1




            The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
            – Gordon Davisson
            Nov 20 at 7:48










          • @GordonDavisson, sure thanks for letting know I have done the changes now.
            – RavinderSingh13
            Nov 20 at 9:29






          • 1




            Thank you all for your help. Much appreciated. :)
            – Warsiders23
            Nov 21 at 0:08


















          up vote
          -1
          down vote













          How about?



          date +%T | sed -e "s/:/ /g"





          share|improve this answer





















          • IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
            – RavinderSingh13
            Nov 20 at 7:13






          • 1




            ah, I see, it should be the better way (y)
            – enpiti
            Nov 20 at 7:21











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: 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%2fstackoverflow.com%2fquestions%2f53387787%2fhow-to-output-the-date-without-a-colon-using-bash-command%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          When I do man date I got:




          %T time; same as %H:%M:%S




          Then why don't we do which will give same output as %T option in date rather than using %T with external or bash tools to get results in different forms:



          date +"%H-%M-%S"
          OR
          date +"%H/%M/%S"
          OR
          date +%H%M%S ##Without any output delimiter





          share|improve this answer



















          • 1




            The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
            – Gordon Davisson
            Nov 20 at 7:48










          • @GordonDavisson, sure thanks for letting know I have done the changes now.
            – RavinderSingh13
            Nov 20 at 9:29






          • 1




            Thank you all for your help. Much appreciated. :)
            – Warsiders23
            Nov 21 at 0:08















          up vote
          4
          down vote



          accepted










          When I do man date I got:




          %T time; same as %H:%M:%S




          Then why don't we do which will give same output as %T option in date rather than using %T with external or bash tools to get results in different forms:



          date +"%H-%M-%S"
          OR
          date +"%H/%M/%S"
          OR
          date +%H%M%S ##Without any output delimiter





          share|improve this answer



















          • 1




            The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
            – Gordon Davisson
            Nov 20 at 7:48










          • @GordonDavisson, sure thanks for letting know I have done the changes now.
            – RavinderSingh13
            Nov 20 at 9:29






          • 1




            Thank you all for your help. Much appreciated. :)
            – Warsiders23
            Nov 21 at 0:08













          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          When I do man date I got:




          %T time; same as %H:%M:%S




          Then why don't we do which will give same output as %T option in date rather than using %T with external or bash tools to get results in different forms:



          date +"%H-%M-%S"
          OR
          date +"%H/%M/%S"
          OR
          date +%H%M%S ##Without any output delimiter





          share|improve this answer














          When I do man date I got:




          %T time; same as %H:%M:%S




          Then why don't we do which will give same output as %T option in date rather than using %T with external or bash tools to get results in different forms:



          date +"%H-%M-%S"
          OR
          date +"%H/%M/%S"
          OR
          date +%H%M%S ##Without any output delimiter






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 20 at 9:57

























          answered Nov 20 at 7:07









          RavinderSingh13

          24.8k41437




          24.8k41437








          • 1




            The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
            – Gordon Davisson
            Nov 20 at 7:48










          • @GordonDavisson, sure thanks for letting know I have done the changes now.
            – RavinderSingh13
            Nov 20 at 9:29






          • 1




            Thank you all for your help. Much appreciated. :)
            – Warsiders23
            Nov 21 at 0:08














          • 1




            The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
            – Gordon Davisson
            Nov 20 at 7:48










          • @GordonDavisson, sure thanks for letting know I have done the changes now.
            – RavinderSingh13
            Nov 20 at 9:29






          • 1




            Thank you all for your help. Much appreciated. :)
            – Warsiders23
            Nov 21 at 0:08








          1




          1




          The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
          – Gordon Davisson
          Nov 20 at 7:48




          The dash and slash are not shell metacharacters, so they don't need to be quoted: date +%H-%M-%S and date +%H/%M/%S would work fine. But actually, I'd use date +"%H-%M-%S" and date +"%H/%M/%S", since they match the semantics (the quoted section being the format string).
          – Gordon Davisson
          Nov 20 at 7:48












          @GordonDavisson, sure thanks for letting know I have done the changes now.
          – RavinderSingh13
          Nov 20 at 9:29




          @GordonDavisson, sure thanks for letting know I have done the changes now.
          – RavinderSingh13
          Nov 20 at 9:29




          1




          1




          Thank you all for your help. Much appreciated. :)
          – Warsiders23
          Nov 21 at 0:08




          Thank you all for your help. Much appreciated. :)
          – Warsiders23
          Nov 21 at 0:08












          up vote
          -1
          down vote













          How about?



          date +%T | sed -e "s/:/ /g"





          share|improve this answer





















          • IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
            – RavinderSingh13
            Nov 20 at 7:13






          • 1




            ah, I see, it should be the better way (y)
            – enpiti
            Nov 20 at 7:21















          up vote
          -1
          down vote













          How about?



          date +%T | sed -e "s/:/ /g"





          share|improve this answer





















          • IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
            – RavinderSingh13
            Nov 20 at 7:13






          • 1




            ah, I see, it should be the better way (y)
            – enpiti
            Nov 20 at 7:21













          up vote
          -1
          down vote










          up vote
          -1
          down vote









          How about?



          date +%T | sed -e "s/:/ /g"





          share|improve this answer












          How about?



          date +%T | sed -e "s/:/ /g"






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 at 7:11









          enpiti

          12413




          12413












          • IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
            – RavinderSingh13
            Nov 20 at 7:13






          • 1




            ah, I see, it should be the better way (y)
            – enpiti
            Nov 20 at 7:21


















          • IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
            – RavinderSingh13
            Nov 20 at 7:13






          • 1




            ah, I see, it should be the better way (y)
            – enpiti
            Nov 20 at 7:21
















          IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
          – RavinderSingh13
          Nov 20 at 7:13




          IMHO, you need not to use external command to get it when date could do it by itself see this once too stackoverflow.com/a/53387878/5866580
          – RavinderSingh13
          Nov 20 at 7:13




          1




          1




          ah, I see, it should be the better way (y)
          – enpiti
          Nov 20 at 7:21




          ah, I see, it should be the better way (y)
          – enpiti
          Nov 20 at 7:21


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2fstackoverflow.com%2fquestions%2f53387787%2fhow-to-output-the-date-without-a-colon-using-bash-command%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

          To store a contact into the json file from server.js file using a class in NodeJS

          Redirect URL with Chrome Remote Debugging Android Devices

          Dieringhausen