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 Answer 1

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)
3
  • That is a great tip!!
    – Josh
    Commented Dec 23, 2010 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. Commented Dec 24, 2010 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. Commented Dec 26, 2010 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .