Can’t pipe into diff

command linediff()pipe

I wanted to be clever and compare a remote file to a local file without first manually downloading it. I can get the contents of the remote file by

ssh user@remote-host "cat path/file.name"

However, piping that to diff

ssh user@remote-host "cat path/file.name" | diff path/file.name

gives me this:

diff: missing operand after `path/file.nae'
diff: Try `diff --help' for more information.

I have ssh keys set up, so it's not prompting me for a password. What's a workaround for this?

Best Answer

Try to use - to represent the standard input.

ssh user@remote-host "cat path/file.name" | diff path/file.name -

Related Question