Convert a string to date format The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election Resultsgrep to see if a line ends with a particular stringPiping bash string manipulationReading a string till a key word and replacing from there with another stringIssues with storing an echo of a date conversion into a string variable inunixHow to get a substring based on index of another stringExtract string from first character till string patternAppending to string in bashecho a string with a string inside of itEfficient way to convert string to single quote in array on Linux shellhow to read a nul-terminated-string from a binary file

Python - Fishing Simulator

Match Roman Numerals

should truth entail possible truth

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Why are PDP-7-style microprogrammed instructions out of vogue?

Drawing vertical/oblique lines in Metrical tree (tikz-qtree, tipa)

Sub-subscripts in strings cause different spacings than subscripts

Can a flute soloist sit?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Word to describe a time interval

Am I ethically obligated to go into work on an off day if the reason is sudden?

Does Parliament hold absolute power in the UK?

Is 'stolen' appropriate word?

Why can't devices on different VLANs, but on the same subnet, communicate?

Do I have Disadvantage attacking with an off-hand weapon?

How to support a colleague who finds meetings extremely tiring?

Why doesn't a hydraulic lever violate conservation of energy?

How do you keep chess fun when your opponent constantly beats you?

What do I do when my TA workload is more than expected?

What aspect of planet Earth must be changed to prevent the industrial revolution?

Are there continuous functions who are the same in an interval but differ in at least one other point?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

University's motivation for having tenure-track positions



Convert a string to date format



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election Resultsgrep to see if a line ends with a particular stringPiping bash string manipulationReading a string till a key word and replacing from there with another stringIssues with storing an echo of a date conversion into a string variable inunixHow to get a substring based on index of another stringExtract string from first character till string patternAppending to string in bashecho a string with a string inside of itEfficient way to convert string to single quote in array on Linux shellhow to read a nul-terminated-string from a binary file



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








0















In Unix i have a file which has information like below



$ cat date.txt 
Mon Apr 8 21:00:42


I Need to convert this as 2019-04-09 00:29:22.



Example:



$ cat date.txt 
Mon Apr 8 21:00:42


--
expected o/p



Mon Apr 8 21:00:42









share|improve this question



















  • 1





    hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

    – RoVo
    Apr 9 at 9:14

















0















In Unix i have a file which has information like below



$ cat date.txt 
Mon Apr 8 21:00:42


I Need to convert this as 2019-04-09 00:29:22.



Example:



$ cat date.txt 
Mon Apr 8 21:00:42


--
expected o/p



Mon Apr 8 21:00:42









share|improve this question



















  • 1





    hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

    – RoVo
    Apr 9 at 9:14













0












0








0








In Unix i have a file which has information like below



$ cat date.txt 
Mon Apr 8 21:00:42


I Need to convert this as 2019-04-09 00:29:22.



Example:



$ cat date.txt 
Mon Apr 8 21:00:42


--
expected o/p



Mon Apr 8 21:00:42









share|improve this question
















In Unix i have a file which has information like below



$ cat date.txt 
Mon Apr 8 21:00:42


I Need to convert this as 2019-04-09 00:29:22.



Example:



$ cat date.txt 
Mon Apr 8 21:00:42


--
expected o/p



Mon Apr 8 21:00:42






string






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 9 at 9:21









RoVo

3,761317




3,761317










asked Apr 9 at 9:00









RamkumarRamkumar

1




1







  • 1





    hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

    – RoVo
    Apr 9 at 9:14












  • 1





    hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

    – RoVo
    Apr 9 at 9:14







1




1





hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

– RoVo
Apr 9 at 9:14





hm, I don't see how you convert 21:00:42 to 00:29:22 or is it just a bad example ? also your expected o/p is the same as the input. Please fix that.

– RoVo
Apr 9 at 9:14










1 Answer
1






active

oldest

votes


















1














You can use date:



date -d "Mon Apr 8 21:00:42" "+%Y-%m-%d %H:%M:%S"


or



date -d "Mon Apr 8 21:00:42" "+%F %X" 


For all lines of a file:



xargs -a date.txt -I date -d "" "+%F %X"



See man date for the FORMAT specification.






share|improve this answer























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f511408%2fconvert-a-string-to-date-format%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You can use date:



    date -d "Mon Apr 8 21:00:42" "+%Y-%m-%d %H:%M:%S"


    or



    date -d "Mon Apr 8 21:00:42" "+%F %X" 


    For all lines of a file:



    xargs -a date.txt -I date -d "" "+%F %X"



    See man date for the FORMAT specification.






    share|improve this answer



























      1














      You can use date:



      date -d "Mon Apr 8 21:00:42" "+%Y-%m-%d %H:%M:%S"


      or



      date -d "Mon Apr 8 21:00:42" "+%F %X" 


      For all lines of a file:



      xargs -a date.txt -I date -d "" "+%F %X"



      See man date for the FORMAT specification.






      share|improve this answer

























        1












        1








        1







        You can use date:



        date -d "Mon Apr 8 21:00:42" "+%Y-%m-%d %H:%M:%S"


        or



        date -d "Mon Apr 8 21:00:42" "+%F %X" 


        For all lines of a file:



        xargs -a date.txt -I date -d "" "+%F %X"



        See man date for the FORMAT specification.






        share|improve this answer













        You can use date:



        date -d "Mon Apr 8 21:00:42" "+%Y-%m-%d %H:%M:%S"


        or



        date -d "Mon Apr 8 21:00:42" "+%F %X" 


        For all lines of a file:



        xargs -a date.txt -I date -d "" "+%F %X"



        See man date for the FORMAT specification.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 9 at 9:12









        RoVoRoVo

        3,761317




        3,761317



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f511408%2fconvert-a-string-to-date-format%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

            getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

            Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

            Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.