0

So I am trying to compare output of two python programs, which have files that I will call trace1.py and trace2.py. Currently I am using process substitution with diff to try and compare their outputs, however I'm having trouble with finding both files, since they are in separate sub-directories of my current directory:

diff <(python /subdir1/tracing1.py) <(python /subdir2/tracing2.py)

When I run this, I get

The system cannot find the file specified.

I think I'm messing up some sort of path formatting, or else I'm using the process substitution incorrectly.

EDIT: In the end I decided that I didn't need to use process substitution, and instead could just diff program output after each program is run. However thanks to Fallenreaper in the comments, I was able to find a single command that does what I initially wanted:

python subdir1/tracing1.py > outfile1.txt & python subdir2/tracing2.py > outfile2.txt & diff outfile1.txt outfile2.txt
10
  • Can you paste the exact command that you are running? What is your directory struc like? Commented Jun 29, 2018 at 20:24
  • 2
    Maybe something like: python /path/tracing1.py &1> outfile1.txt & python /path/tracing2.py &1 >outfile2.txt & diff outfile1.txt outfile2.txt Commented Jun 29, 2018 at 20:24
  • 1
    If subdir1 and subdir2 are subdirectories of the current directory (and not root-level directories), you probably mean subdir1/tracing1.py (without the leading slash). Commented Jun 29, 2018 at 20:28
  • @Fallenreaper Process substitution captures both output to stdout and stderr, see for example diff <(echo blah >&2) <(echo blahx), so I don't think that's the problem. Commented Jun 29, 2018 at 20:28
  • Honestly come to think of it, I don't even need to run both programs one after another. So really I can just redirect output to two separate files and then diff after. I guess I was over complicating things in the end. I guess my curiosity with the error made me want to ask. Commented Jun 29, 2018 at 20:33

1 Answer 1

1

Sorry, not enough rep to comment yet :( Your line works perfectly when you remove that slash. I would suggest using absolute path names or a relative path from current directory cos that front slash would take you to your root directory.

Cheers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.