Normally you would write:
diff file1 file2
But I would like to diff a file and output from the command (here I make command a trivial one):
diff file1 <(cat file2 | sort)
Ok, this work when I enter this manually at shell prompt, but when I put exactly the same line in shell script, and then run the script, I get error.
So, the question is -- how to do this correctly?
Of course I would like avoid writing the output to a temporary file.
-R
in case of usinggit diff --no-index
– Nakilon Jan 04 '18 at 21:49diff - file1
. – Caleb Jan 05 '18 at 06:53git diff
. – Nakilon Jan 06 '18 at 04:49git diff
is a completely different beast and operates on references to glob objects in its internal index, not files;diff
operates on the file system. The-
syntax is just shell syntactic sugar for/dev/stdin
, the file representing the STDIN stream. Hence whydiff
can use it as a substitute for a file name. Meanwhilegit diff
isn't looking for files, it's looking up objects so you have to pass it something it recognizes. Don't use it to compare files to each other, usediff
for that. – Caleb Jan 09 '18 at 12:45