Sed pipe for differentiation

I want to see diffbetween the paragraph in the middle of the file and the file containing one paragraph.

A paragraph is in the line of the 60file foo, and the file barcontains only this paragraph with possible minor differences.

I can remove this paragraph, using sed: sed -n 60,60p foo. How can i use this in diff?

The following steps do not work:

sed -n 60,60p foo | diff bar # diff: missing operand after `foo`
diff bar `sed -n 60,60p foo` # diff: extra operand `in`

I can do:

sed -n 60,60p foo >> tempfile; diff bar tempfile

Is there a solution that does not require me to temporarily store using a channel?

+5
source share
2 answers

If you use the file argument “-” as a file, it diffwill read from stdin:

  sed -n 60,60p foo | diff bar -
+9
source

You can use process substitution:

diff bar <(sed -n 60,60p foo)

:

diff <(sed -n 60,60p bar) <(sed -n 60,60p foo)
+7

All Articles