How after a long wait for the output to save what I saw in the file?

Let's say by command:

git grep <regexp> $(git rev-list --all) 

I understand that it would be prudent to have > log.txt at the end, I want to immediately save what I saw?

I figured it out myself, the essence is as follows. If we just allow typing just git log , a browse dialog will appear with the icon : This screen can be moved up and down there, but if you press the s button, then the dialog for entering the file name appears, you only need to type in log.txt and all the output will be saved to this file

  • Do you want to see and save at the same time? - KoVadim
  • I need to save what I saw. this operation takes a very long time if there are many commits - RinatV
  • association: stackoverflow.com/q/418896 - mymedia

2 answers 2

To see the output and save it at the same time there is a special command tee , example:

 command | tee log.txt 

Scheme explaining the work of the tee team Illustration: Wikipedia , GFDL .

  • I know this command, I use it from time to time, however I cannot remember it all the time and insert it where necessary and inappropriately. this operation takes a very long time if there are many commits - RinatV
  • Most terminals support logging. Customize yourself and will not forget. But I think it will help to simply increase the buffer for the terminal - then scrolling will be available. - KoVadim

If not for a single command, but for a "session", then I use the script command
(the entire work protocol will be in the ./typescript file, but in general, see man script ).