0

I need to find difference between 2 Cmd outputs. I found this Cmd for Linux but it is not working for Unix AIX server.

diff <(cmd1) <(cmd2)

Please let me know the equivalent UNIX command.

fedorqui
  • 275,237
  • 103
  • 548
  • 598

1 Answers1

1

The command you refer to is using process substitution, i.e. the <(...) part. Essentially, it takes the output of the cmd1 and presents it as though it were a named file in the filesystem to diff. It is a feature of the bash shell, so, for a start you need to ensure you are using bash and not sh.

If that doesn't solve the problem, you could try downloading and installing the latest bash for AIX.

If that doesn't work, you need to use 2 temporary files, something like this (or using mktemp):

cmd1 > tmp1_$$
cmd2 > tmp2_$$
diff tmp1_$$ tmp2_$$
rm tmp?_$$
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • 1
    I believe the <(...) syntax also ses the /dev/fd/N device driver which AIX does not have. bash has to pass some path to diff for it to open. On Unix, if the fd is open on fd 5, then /dev/fd/5 will also open that same fd. – pedz Oct 12 '14 at 12:50