Same here, except I typically use $(!!) to re-run the previous command. I find it faster than command-line editing.
$ find . -name "*blarg*.cpp"
$ grep -i "blooey" $(!!)
$ vim $(!! -l)
Granted, you can only append new arguments and using the other ! commands will often be less practical than editing. Still, it's amazing how frequently this is sufficient.I've always thought it'd be nice if there was a `set` option or something similar that would make bash record command lines and cache output automatically in implicit variables, so that it doesn't re-run the commands. The semantics are definitely different and you wouldn't want this enabled at all times, but for certain kinds of sessions it would be very handy.
EDIT: lazyjones beat me to it.
Since "!!" are replaced when you hit the "up" arrow key (i.e. jump to previous command), you can go really wild with them:
Re:The Mighty Named Pipe
by icebraining on Wednesday March 11, 2015 @07:57AM
(#9183595)
That's actually command substitution, not process substitution :)
Thanks for the correction. The unix is large and I'm so very small.
And command substitution has nothing to do with pipes, named or unnamed.
> Command line editing makes this trivial.
I'm lazy, so I typically do this (2nd step) to avoid the extra key strokes necessary for editing:
$ grep -i "blooey" $(!!)
Also very useful for avoiding editing in order to do something else with the same argument as in the previous command: !$, i.e.: $ foo myfile
$ bla !$You could just use a pipe here though, which would also make it more easy to read. e.g.:
$ find . -name '*blarg*.cpp' | grep -li blooey | vi -
Re:The Mighty Named Pipe
by icebraining on Wednesday March 11, 2015 @08:07AM
(#9183630)
Your version searches for blooey in the filenames, not in the files themselves.
Re:The Mighty Named Pipe
by reitanqild on Wednesday March 11, 2015 @08:23AM
(#9183671)
And, to try to be helpful, - seems it lacks an xargs (or similar construct)
I used to do it something like that, but I find it personally easier to understand the way I described it and evolved into that. I also like what I'm ultimately doing (vim/vi in this case) to be over on the left: edit whatever this mess on the right produces.
Very often I do something like this in quick succession. Command line editing makes this trivial.