5

I think the correct operator for executing subshell command in tcsh is the backtick ` but when I attempt to do a diff on the results of two commands I get an error. When I direct the information to files first and do a diff on the two files I get exactly what I want but I'd rather just use a single command like:

diff `jar -tvf org.jar` `jar -tvf new.jar`

What is the correct syntax in tcsh?

1 Answers1

6

You have the correct syntax for a command substitution. But what you need to pass to diff are two file names, not two file contents, which is what you're trying to pass. (What you're actually passing is in fact more complicated, but if you'd written diff "`jar -tvf org.jar`" "`jar -tvf new.jar`", you'd be passing two file contents.)

I don't think tcsh has a way to do what you're trying to do, without creating a temporary file. In ksh, bash or zsh, you can do it this way:

diff <(jar -tvf org.jar) <(jar -tvf new.jar)
  • That is a great tip!! – Josh Dec 23 '10 at 22:51
  • I tried the double quoting around the backwards quote and diff still is looking for two filename arguments. I think for bash you need diff < $(jar -tvf org.jar) < $(jar -tvf new.jar) but even this is giving an ambiguous redirect error. It seems like you can't have two inputs to diff regardless of the shell. Somehow I need to convert the inputs into temp files or use a different command that compares input streams and not files. – Andrew Stern Dec 24 '10 at 17:36
  • 1
    @Andrew: No, I did mean <(…), it's what bash calls process substitution. It is a way to pass several inputs (or less frequently obtain several outputs) from a program. As far as I know tcsh doesn't have anythinig similar. – Gilles 'SO- stop being evil' Dec 26 '10 at 10:57