Bash / command line zsh output

I looked around, but have not yet found an answer. I'm Bash / Zsh, I know the variation

echo !! 
echo !$

etc. But is there a way to remember the last output line? I know that I can just edit the line and add some information about the pipelines, but I was wondering if there was an alternative. To illustrate this, I can do the following

ls -tr
vim {whatever key to recall the last line}

which will allow me to edit the last file.

If a similar question has already been asked, and I could not find it, could you redirect me to it?

+3
source share
2 answers

I think you're out of luck. Potentially, the shell would have to store a huge amount of information (imagine a long process and its output).

In your example:

ls -tr
vim {whatever key to recall the last line}

, :

ls -tr
vim $(!!)

, vim.

+3

, . , :

> script --flush /tmp/myscript
Script started, file is /tmp/myscript
> LASTLINE() {
     tail -2 /tmp/myscript | head -1 | tr -d '\r'
  }
> bind '"^[[15~":"$(LASTLINE)\n"'
> ls -tr1
file1
file2
fileN
> vi [press F5]

: script , . "/tmp/myscript", , , . (vi ...) ​​ "myscript", . ( , tr.) LASTLINE F5 ( bash, ?, , ). F5, .

, , - (- script), exit, .

: bash. ,   .

+2