1

there is a file, let's call it a reference file, you need to execute the script and compare the reference file with it, a file of 132 kb

result=$(./test.sh)| cmp -s $result test && echo 1||echo 0

I get the wrong output, the test file is identical to the script output, but I get 0

1
  • 1
    What's the point of the pipe (|) in your command? There is no command to the left of it, and cmp is ignoring stdin anyway, unless a sole - is passed on the commandline (see man cmp). Commented Nov 18, 2022 at 12:31

1 Answer 1

3

Just pipe the script's output to cmp.

./script | cmp -s - file
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.