Reputation: 21389
I am aware that it's possible to do stuff like
echo `ls` "foobar"
echo $(ls) "foobar"
but when I try to do something like
diff `pip freeze` requirements.txt
diff $(pip freeze) requirements.txt
it fails.
What am I missing here? Thanks!
P.S I am using zsh
shell.
Upvotes: 3
Views: 2380
Reputation: 157967
The diff
command does expect file names as it's arguments, not strings. Something like:
diff file1 file2
but not:
diff "$string1" "$string2"
If you want to diff the output of two commands (or in your case the output of a command against a static file) you can use process substitution:
diff <(pip freeze) requirements.txt
The <()
will redirect the output of pip freeze
into a file at /dev/fd[0-9]
. This file name will then getting passed to diff
.
Upvotes: 8