15

I am trying to compare two command output (no files)

vimdiff "$(tail /tmp/cachain.pem)" "$(tail /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem)"

I tried playing with redirection, pipe, and vim - -c but I must be missing something. Can anyone help please ?

21

You are confusing $(…) with <(…). You used the former, which passes the output as arguments to vimdiff. For example, if the last line of /path/to/foo contains bar bar bar, then the following command

echo $(tail -1 /path/to/foo)

is equivalent to

echo bar bar bar

Instead, you need to use <(…). This is called process substitution, and passes the output as a pseudo-file to the vimdiff command. Hence, use the following.

vimdiff <(tail /tmp/cachain.pem) <(tail /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem)

This works in bash and zsh, but apparently there is no way to do process substitution in tcsh.

  • this is only in bash, though – simona May 31 '18 at 11:10
  • @simona Works for me in zsh too. Probably csh and tcsh as well. – Sparhawk May 31 '18 at 12:27
  • @Sparhawk it doesn't work in tcsh – simona May 31 '18 at 15:47
  • @simona Thanks for that information; I'm not familiar with tcsh. You might consider putting up an answer that works in tsch. Cheers. – Sparhawk Jun 1 '18 at 1:59
  • @Sparhawk apparently there is no way to this in tcsh without creating a file unix.stackexchange.com/questions/5111/… – simona Jun 1 '18 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.