Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

copy text from the output of a previous command (using only keyboard, not mouse)

How can I copy text from a previous command’s output in bash using only keyboard (not mouse)

$ ./my_lovely_program input.txt
eggs
sugar
flour
$ <----- any way to move "up" and yank / copy the word "sugar" ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Once something is printed, it is gone, and bash does not know anything about it anymore. bash can intercept your keystrokes, but does not have stored anywhere the previous output. The best you could do is to use tee:

./my_lovely_program input.txt | tee some_file

where some_file would contain the standard output of your program.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading