I want to make a shell script which copies the past outputs of the GUI terminal emulator (for example, last 20 lines). The motivation is as following:
When I execute a procedure which requires long time (for example, downloading a very large file, or converting a very large movie file), I sometimes remember another job, and I have to leave the room. In such a case, I press ctrl+z to stop the procedure. And I type
fg; echo $? >> log.txt; date >> log.txt; systemctl poweroff
then I leave the room.
This way works and is not bad. But it has a disadvantage that I cannot read the outputs of the procedure. I can know only the status ($?). So I want to copy last 20 or 40 lines and save them in log file.