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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With