0

I executed the command and it took quite a long time; now it is necessary to work with this output, but I realized it too late. Executing the command again is not a good idea.

I know that can select and copy the output to a file, but that's not a good option either because the output can be very big.

Are there any other options for solving this problem? Maybe by using osascript it is possible in some way to quickly copy or write to the file the last output?

1
  • 1
    There isn't really a way to do this; command output is sent to the Terminal, but not recorded anywhere else (and if it's overwritten or erased from the Terminal buffer, it's gone). Plan ahead, and pipe the output through tee to save it to a temp file. Commented Mar 17, 2022 at 1:25

1 Answer 1

2

I think there are two options. You can either save the output to a variable like this:

output=$(echo test)
echo $output

The result will be:

> test

Or you can save it to a file:

echo test >> output.txt

Your output.txt will have the following content:

test

If you just want to store the output you should use the file option, if you want to run further commands with the output use the variable.

You must log in to answer this question.

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