8

Am I able to compare two different urls/websites without downloading the file first using wget or something similar first. I tried the following, but received the below error.

[root@desktop ~]# diff http://www.example.net/index.php http://www.example.com/index.php
diff: http://www.example.net/index.php: No such file or directory
diff: http://www.example.com/index.php: No such file or directory
[root@desktop ~]#
user1032531
  • 22,993
  • 61
  • 191
  • 346

1 Answers1

15

Of course you can use curl, although it is a bit strange:

diff <(curl url1) <(curl url2)

In your case:

diff <(curl http://www.example.net/index.php) <(curl http://www.example.com/index.php)

Note you can use curl -s for a cleaner diff execution.

fedorqui
  • 252,262
  • 96
  • 511
  • 570
  • Thanks fedorqui, Is `curl` preferred over Paulloz's example with `echo`? – user1032531 Mar 25 '14 at 10:57
  • `curl` will compare pages itself, while `echo` the strings. – fedorqui Mar 25 '14 at 10:57
  • OK, I'm interested @fedorqui. Why is using curl to do diff 'a bit strange'? – notapatch Oct 21 '15 at 12:35
  • 2
    @Rich I said "a bit strange" because of the syntax. We normally say `diff file1 file2`, whereas using [process substitution](http://stackoverflow.com/a/31703275/1983854) looks a bit weird the first. But it is completely valid and a very useful way to do it once you learn it : ) – fedorqui Oct 21 '15 at 16:07