Save output of previous command to a text file

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








up vote
1
down vote

favorite












Suppose I ran some command, and now want to save the output of that previous command to a text file (without re-running the command, of course, there's no reason to assume it's idempotent).



Is there some simple way to get that output of the previous command?



echo <magic_for_last_output> >file.txt









share|improve this question



















  • 1




    Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
    – Apollys
    Mar 14 at 19:35







  • 1




    You could use script to log your bash session.
    – glenn jackman
    Mar 14 at 20:12














up vote
1
down vote

favorite












Suppose I ran some command, and now want to save the output of that previous command to a text file (without re-running the command, of course, there's no reason to assume it's idempotent).



Is there some simple way to get that output of the previous command?



echo <magic_for_last_output> >file.txt









share|improve this question



















  • 1




    Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
    – Apollys
    Mar 14 at 19:35







  • 1




    You could use script to log your bash session.
    – glenn jackman
    Mar 14 at 20:12












up vote
1
down vote

favorite









up vote
1
down vote

favorite











Suppose I ran some command, and now want to save the output of that previous command to a text file (without re-running the command, of course, there's no reason to assume it's idempotent).



Is there some simple way to get that output of the previous command?



echo <magic_for_last_output> >file.txt









share|improve this question















Suppose I ran some command, and now want to save the output of that previous command to a text file (without re-running the command, of course, there's no reason to assume it's idempotent).



Is there some simple way to get that output of the previous command?



echo <magic_for_last_output> >file.txt






command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 at 20:52









Zanna

48.1k13120228




48.1k13120228










asked Mar 14 at 19:09









Apollys

1063




1063







  • 1




    Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
    – Apollys
    Mar 14 at 19:35







  • 1




    You could use script to log your bash session.
    – glenn jackman
    Mar 14 at 20:12












  • 1




    Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
    – Apollys
    Mar 14 at 19:35







  • 1




    You could use script to log your bash session.
    – glenn jackman
    Mar 14 at 20:12







1




1




Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
– Apollys
Mar 14 at 19:35





Just found: stackoverflow.com/questions/24283097/…, it looks like hacking bash would be the necessary route to accomplishing this...
– Apollys
Mar 14 at 19:35





1




1




You could use script to log your bash session.
– glenn jackman
Mar 14 at 20:12




You could use script to log your bash session.
– glenn jackman
Mar 14 at 20:12










1 Answer
1






active

oldest

votes

















up vote
1
down vote













No, there isn't a way to save the last command's output to a file, as far as I know. The shell doesn't store that information.



However, you can hit the up arrow &uparrow; and add the redirection to the end of the last command, so you don't have to type anything new.






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%2f1014967%2fsave-output-of-previous-command-to-a-text-file%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    No, there isn't a way to save the last command's output to a file, as far as I know. The shell doesn't store that information.



    However, you can hit the up arrow &uparrow; and add the redirection to the end of the last command, so you don't have to type anything new.






    share|improve this answer


























      up vote
      1
      down vote













      No, there isn't a way to save the last command's output to a file, as far as I know. The shell doesn't store that information.



      However, you can hit the up arrow &uparrow; and add the redirection to the end of the last command, so you don't have to type anything new.






      share|improve this answer
























        up vote
        1
        down vote










        up vote
        1
        down vote









        No, there isn't a way to save the last command's output to a file, as far as I know. The shell doesn't store that information.



        However, you can hit the up arrow &uparrow; and add the redirection to the end of the last command, so you don't have to type anything new.






        share|improve this answer














        No, there isn't a way to save the last command's output to a file, as far as I know. The shell doesn't store that information.



        However, you can hit the up arrow &uparrow; and add the redirection to the end of the last command, so you don't have to type anything new.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 14 at 20:54

























        answered Mar 14 at 19:15









        Zanna

        48.1k13120228




        48.1k13120228



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1014967%2fsave-output-of-previous-command-to-a-text-file%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            Which professions warranted travel in Medieval times?

            How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

            Trouble downloading packages list due to a “Hash sum mismatch” error