从上一个命令的输出中复制文本(仅使用键盘,不使用鼠标)

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

如何使用键盘(而非鼠标)

复制bash中先前命令输出的文本
$ ./my_lovely_program input.txt
eggs
sugar
flour
$ <----- any way to move "up" and yank / copy the word "sugar" ?

一旦打印出来,它就消失了,bash对它一无所知。 bash 可以拦截您的击键,但不会在任何地方存储以前的输出。你能做的最好的就是使用 tee:

./my_lovely_program input.txt | tee some_file

其中 some_file 将包含程序的标准输出。