Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:43:04+00:00 2026-06-15T15:43:04+00:00

I have to compare a file with 3 different golden files using diff .

  • 0

I have to compare a file with 3 different golden files using diff.
I need to exit the script with exit 0 if test file is the same as any of the three golden files.

I tried the following:

#!/bin/sh
one=`diff -q NEW_GOLDEN_OUTPUT_ASYNC_1 /tmp/tmp_last_lines.log`
two=`diff -q NEW_GOLDEN_OUTPUT_ASYNC_2 /tmp/tmp_last_lines.log`
three=`diff -q NEW_GOLDEN_OUTPUT_ASYNC_3 /tmp/tmp_last_lines.log`

if [[ $one || $two || $three ]]; then
  exit 0
else
  exit 1
fi

But it returns exit 0 in all cases. I’m using /bin/ksh shell. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:43:05+00:00Added an answer on June 15, 2026 at 3:43 pm

    Your code looks at the output of diff but you should look at the exit code. Try this instead:

    #!/bin/sh
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_1 /tmp/tmp_last_lines.log && \
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_2 /tmp/tmp_last_lines.log && \
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_3 /tmp/tmp_last_lines.log
    

    && will only execute the next command if the previous one succeeded.

    Alternatively, use set -e (Exit immediately if a command exits with a non-zero status.):

    #!/bin/sh
    set -e
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_1 /tmp/tmp_last_lines.log
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_2 /tmp/tmp_last_lines.log
    diff -q NEW_GOLDEN_OUTPUT_ASYNC_3 /tmp/tmp_last_lines.log
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IntelliJ lets you compare a file with a different release of the same file.
I have some css files and I want to compare and copy the different
I have a file with my lines and I want to compare lines that
In my .jsp file I have the code below. How can I compare the
I have to compare three dates in linq query (datetime a < datetime b
I have template function compare defined as below. #include<iostream> using namespace std; template<typename T>
I have been using SQL Compare by Redgate at my company and was very
hey i have a requirement , where i have to compare a file name
We have to compare responses (XML) of two different but they are doing the
I have an eclipse project containing a source file. Now I have a different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.