2

I have an incremental build command for my project that will output something if I do a clean build, and output something else (less) if I do an incremental build.

Say, I forgot to do this:

mycommand.sh > myfile.txt

or this

mycommand.sh >> myfile.txt

for saving the output to a file.

How can I save this if I already run a clean build mycommand.sh and the output is printed on terminal window (without using copy paste)?

2
  • you can do something like that with kitty, havnt tested it myself
    – user986805
    Apr 12, 2020 at 17:44
  • To be clear, this question is absolutely on topic here. Such questions are very welcome.
    – Zanna
    Sep 10, 2020 at 18:42

1 Answer 1

-1

You can use $(!!) to view the output of the last executed command.

my_command
echo $(!!)

Example:

ls $HOME
echo $(!!)
1
  • 2
    it would be good to explain that this runs the last command again, which will not always give the same result, rather than magically retrieving the output. One may as well just hit the up arrow and append > file...
    – Zanna
    Sep 11, 2020 at 2:27

Not the answer you're looking for? Browse other questions tagged .