News for hackers. Stuff that matters.
Re:The Mighty Named Pipe by a3n on Wednesday March 11, 2015 @07:29AM (#9183544)
Named pipes have been rare for me, but simple process substitution is every day.

Very often I do something like this in quick succession. Command line editing makes this trivial.

  $ find . -name "*blarg*.cpp"
  # Some output that looks like what I'm looking for.
  
  # Run the same find again in a process, and grep for something.
  $ grep -i "blooey" $(find . -name "*blarg*.cpp")
  
  # Yep, those are the files I'm looking for, so dig in.
  # Note the additional -l in grep, and the nested processes.
  $ vim $(grep -il "blooey" $(find . -name "*blarg*.cpp"))
Re:The Mighty Named Pipe by tne on Wednesday March 11, 2015 @08:38AM (#9183721)
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.

Re:The Mighty Named Pipe by vog on Wednesday March 11, 2015 @08:51AM (#9183772)
Since "!!" are replaced when you hit the "up" arrow key (i.e. jump to previous command), you can go really wild with them:

https://oeis.org/A228162

Re:The Mighty Named Pipe by icebraining on Wednesday March 11, 2015 @07:57AM (#9183595)
That's actually command substitution, not process substitution :)
Re:The Mighty Named Pipe by a3n on Wednesday March 11, 2015 @09:57AM (#9184065)
Thanks for the correction. The unix is large and I'm so very small.
Re:The Mighty Named Pipe by hollerith on Wednesday March 11, 2015 @09:34AM (#9183948)
And command substitution has nothing to do with pipes, named or unnamed.
Re:The Mighty Named Pipe by lazyjones on Wednesday March 11, 2015 @08:23AM (#9183670)
> 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 !$
Re:The Mighty Named Pipe by jbnicolai on Wednesday March 11, 2015 @07:59AM (#9183603)
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)
Re:The Mighty Named Pipe by a3n on Wednesday March 11, 2015 @09:56AM (#9184062)
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.