Diff output from two programs without temporary files

后端 未结 6 1020
梦谈多话
梦谈多话 2021-01-29 18:13

Say I have too programs a and b that I can run with ./a and ./b.

Is it possible to diff their outputs without first w

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-29 18:57

    Use <(command) to pass one command's output to another program as if it were a file name. Bash pipes the program's output to a pipe and passes a file name like /dev/fd/63 to the outer command.

    diff <(./a) <(./b)
    

    Similarly you can use >(command) if you want to pipe something into a command.

    This is called "Process Substitution" in Bash's man page.

提交回复
热议问题