Skip to main content
added 395 characters in body
Source Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

UseIf you want to diff the output of some commands, use process substitution <(...) instead of command substitution $(...). Otherwise that seems it should work.

diff $(foo) puts the output of foo on the command line of diff, while diff wants the name of a file to read. diff <(foo) arranges for the output of foo to be available from an fd, and gives diff a pathname that corresponds to the already-opened fd (/dev/fd/NN, might be system-specific).


Though reading the question again, maybe you'd just want to do something like this:

for f in *.wav ; do b=${f%.wav} if [ -f "$b.mp3" ] ; then echo "$b.mp3 exists" ; else echo "$b.mp3 missing" ; fi done 

That would tell if all .wav files in the directory have a corresponding .mp3 file. (But wouldn't show any .mp3 files that don't have a corresponding .wav, of course.)

Use process substitution <(...) instead of command substitution $(...). Otherwise that seems it should work.

diff $(foo) puts the output of foo on the command line of diff, while diff wants the name of a file to read. diff <(foo) arranges for the output of foo to be available from an fd, and gives diff a pathname that corresponds to the already-opened fd (/dev/fd/NN, might be system-specific).

If you want to diff the output of some commands, use process substitution <(...) instead of command substitution $(...). Otherwise that seems it should work.

diff $(foo) puts the output of foo on the command line of diff, while diff wants the name of a file to read. diff <(foo) arranges for the output of foo to be available from an fd, and gives diff a pathname that corresponds to the already-opened fd (/dev/fd/NN, might be system-specific).


Though reading the question again, maybe you'd just want to do something like this:

for f in *.wav ; do b=${f%.wav} if [ -f "$b.mp3" ] ; then echo "$b.mp3 exists" ; else echo "$b.mp3 missing" ; fi done 

That would tell if all .wav files in the directory have a corresponding .mp3 file. (But wouldn't show any .mp3 files that don't have a corresponding .wav, of course.)

Source Link
ilkkachu
  • 148k
  • 16
  • 268
  • 441

Use process substitution <(...) instead of command substitution $(...). Otherwise that seems it should work.

diff $(foo) puts the output of foo on the command line of diff, while diff wants the name of a file to read. diff <(foo) arranges for the output of foo to be available from an fd, and gives diff a pathname that corresponds to the already-opened fd (/dev/fd/NN, might be system-specific).