[Techtalk] finding added lines in a file

Akkana Peck akkana at shallowsky.com
Sat Aug 17 01:39:23 UTC 2013


> Little Girl wrote:
> >comm -1 -3 <(sort A.txt) <(sort B.txt)

Miriam English writes:
> Oops, I meant comm, not comp. My brain is still a bit fuzzy. :)
> I haven't used parentheses like that. I usually use backticks, but
> this might actually be clearer.

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.

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.

Thanks, Little Girl! I'll definitely use that.

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

Shells are awesome. :-)

	...Akkana


More information about the Techtalk mailing list