Diff output from two programs without temporary files

后端 未结 6 942
梦谈多话
梦谈多话 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:48

    Adding a little more to the already good answers (helped me!):

    The command docker outputs its help to STD_ERR (i.e. file descriptor 2)

    I wanted to see if docker attach and docker attach --help gave the same output

    $ docker attach

    $ docker attach --help

    Having just typed those two commands, I did the following:

    $ diff <(!-2 2>&1) <(!! 2>&1)

    !! is the same as !-1 which means run the command 1 before this one - the last command

    !-2 means run the command two before this one

    2>&1 means send file_descriptor 2 output (STD_ERR) to the same place as file_descriptor 1 output (STD_OUT)

    Hope this has been of some use.

提交回复
热议问题