0

I have a series of commands like

$ touch path/to/file.cc
$ less path/to/file.cc
...

and in the second command I'd like to automatically insert the path used in the previous command. Is there a way to do this in the shell? I use zsh, but would be interested in answers for bash or other shells.

What if the most recent command has two filepaths in it? Is there a good way to pick one? And what if there are commands between the current command and the most recently used command that contains a valid filepath?

JeremyKun
  • 314
  • What determines whether a pathname is valid or invalid? What distinguishes a pathname from an option or some other string occurring as an operand or other argument? – Kusalananda Apr 12 '23 at 17:09

0 Answers0