Reputation: 6132
It seems like this should be pretty easy but it's not intuitive to me how to do it. I have two files and I want to diff their first columns (this is an example, I'm sure there are other ways to do this). So I might do cut -d, -f1 file1 > tmp1
, cut -d, -f1 file2 > tmp2
and then diff tmp1 tmp2
. But I want to do it without using the tmp files.
An example of the sort of thing I'm expecting would be ((cut -d, -f1 file1), (cut -d, -f1 file2)) > diff
but this is not real code.
Is there a way to do this?
Upvotes: 9
Views: 2364
Reputation: 3269
Another way to do this is:
cut -d, -f1 file1 | diff - <(cut -d, -f1 file2)
Upvotes: 2
Reputation: 157927
Good news! You can use process substitution in bash:
diff <(cut -d, -f1 file1) <(cut -d, -f1 file2)
Upvotes: 13