diff
operates on files, not on content passed in parameter. Command substitution ($(...)
) replaces the command with its content, this is not the tool you need.
What you actually need is what is called process substitution (<(...)
), which replaces the command with a pseudo-file (actually a pipe) that contains (actually conveys) the result of the command, which is executed in a sub-process.
diff <(curl "https://raw.githubusercontent.com/dockerfile/ubuntu/master/README.md") \
<(curl "https://raw.githubusercontent.com/dockerfile/ubuntu/master/Dockerfile")
Unfortunately, as you added in note, this is a bash
extension that is not known to POSIX shells (/bin/sh
). To my knowledge, there is no solution with /bin/sh
and you have to save at least one of the two curl
outputs in a file:
$ tmp=$(mktemp)
$ curl -o "$tmp" "https://raw.githubusercontent.com/dockerfile/ubuntu/master/README.md"
$ curl "https://raw.githubusercontent.com/dockerfile/ubuntu/master/Dockerfile" \
| diff "$tmp" -
$ rm -f "$tmp"