If you don't mind running the command again: press Up and append an xargs
command. Or use history substitution and run
!! | xargs vim # won't work with file names containing \'" or whitespace
!! | xargs -d \\n vim # GNU only (Linux, Cygwin)
There's a lightweight way of saving the output of a command that works in ksh and zsh but not in bash (it requires the output side of a pipeline to be executed in the parent shell). Pipe the command into the function K
(zsh definition below), which keeps its output in the variable $K
.
function K {
K=("${(@f)$(tee /dev/fd/3)}") 3>&1;
}
find … |K
vim $K
Automatically saving the output of each command is not really possible with the shell alone, you need to run the command in an emulated terminal. You can do it by running inside script
(a BSD utility, but available on most unices including Linux and Solaris), which saves all output of your session through a file (there's still a bit of effort needed to reliably detect the last prompt in the typescript).
vim $(find -name somefile.txt)
works but I'm always annoyed to have to do this, especially when the command inside the$(...)
is usually the last command you entered and I just want to pipe it to vim.pvim
does that - http://unix.stackexchange.com/a/30208/14810 – sente Jan 28 '12 at 04:33vim \
find -name somefile.txt``. @StuartPowers Alternatively, you can usevim \
!-1`` if you already used this find was you previous command – Bernhard Jan 28 '12 at 09:06-o Reopen stdin as /dev/tty in the child process before executing the command. This is useful if you want xargs to run an interactive application.
– davidmh Dec 21 '13 at 00:06https://stackoverflow.com/a/13555918
– user197292 Aug 23 '17 at 03:49find . -name '*file_name*' -exec vim -p {} +;
– dosentmatter Sep 05 '18 at 22:09echo 'someletters_12345_moreleters.ext' | cut -d'_' -f 2
- https://stackoverflow.com/questions/428109/extract-substring-in-bash/428118#428118 – FantomX1 Apr 27 '21 at 15:03