[Techtalk] finding added lines in a file

Little Girl littlergirl at gmail.com
Sat Aug 17 17:15:55 UTC 2013


Hey there,

Akkana Peck wrote:
> > Little Girl wrote:
> > >comm -1 -3 <(sort A.txt) <(sort B.txt)
 
> I've used backquotes plenty, but I'd never seen that <() before.
> That's lovely! It's not the same as backquotes: backquotes let you
> replace arguments, while <(...) stand in for the contents of a file.

I hadn't either. I found it somewhere the other day while playing
around with Miriam's scenario. Apparently it's called process
substitution, and it's kind of interesting. Here's some more on it by
people who put it through its paces:

http://wiki.bash-hackers.org/syntax/expansion/proc_subst

http://tldp.org/LDP/abs/html/process-sub.html

> Playing with it to see if it really did what it looked like it did,
> I tried this (and it worked just fine):
 
> $ diff <(echo hello; echo there) <(echo hello; echo world)
 
> I don't think there's any way of doing that with backquotes.

No idea, but if there is, we could probably find it. (:
 
> Thanks, Little Girl! I'll definitely use that.

Any time - it was fun! (:
 
> I tweeted it, and a friend who is a zsh master gave me a similar
> cool trick:
 
> In zsh only,
> $ echo hi > >(cat) > >(cat -n)
> lets you pipe the output of a command to more than one other
> command.
 
> But in bash, you can use tee with >() to do the same thing:
> $ echo hi | tee >(cat) | cat -n

Oh, totally cool!

> Shells are awesome. :-)

Agreed, although I still have much to learn. (:

-- 
Little Girl

There is no spoon.


More information about the Techtalk mailing list