Save output of previous command to a text file
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
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
command-line
add a comment |Â
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
command-line
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 usescript
to log your bash session.
â glenn jackman
Mar 14 at 20:12
add a comment |Â
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
command-line
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
command-line
edited Mar 14 at 20:52
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
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 usescript
to log your bash session.
â glenn jackman
Mar 14 at 20:12
add a comment |Â
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 usescript
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
add a comment |Â
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 ↑ and add the redirection to the end of the last command, so you don't have to type anything new.
add a comment |Â
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 ↑ and add the redirection to the end of the last command, so you don't have to type anything new.
add a comment |Â
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 ↑ and add the redirection to the end of the last command, so you don't have to type anything new.
add a comment |Â
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 ↑ and add the redirection to the end of the last command, so you don't have to type anything new.
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 ↑ and add the redirection to the end of the last command, so you don't have to type anything new.
edited Mar 14 at 20:54
answered Mar 14 at 19:15
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
![](https://i.stack.imgur.com/8CW8e.png?s=32&g=1)
Zanna
48.1k13120228
48.1k13120228
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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