Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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)
share|improve this answer
    
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 Dec 26 '10 at 10:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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