Save output of previous command to a text file


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


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


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