Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to compare the output from a bash script with a file?

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just pipe the script’s output to cmp.

./script | cmp -s - file
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading