Check two files are same or not coderinme

Check two files are same or not coderinme

Check two files are  same or not? What does this mean!

File comparison

If you have a large file or a large number of files and you want to compare it without view, then the following code is written in the shell script
Please make note that This is the question often found on every assignment of linux and shell programming.

now let’s code ” Check two files are  same or not”

#!/bin/bash
(bash copy)
if [ $# -lt 2 ]; then
echo "Usage: $0 filename1 filename2"
exit 1
fi
if [ ! -e $1 -o ! -e $2 ]; then
echo "File 1 or File 2 don't exists"
exit 2
fi
(cmp -s $1 $2)
if [ $? -ne "0" ]; then
echo "Files are not same"
else
echo "Files are similiar"
#rm $2
fi

For more Linux questiom

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

A web developer(Front end and Back end), and DBA at csdamu.com. Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me @about.me/s.saifi

Leave a reply:

Your email address will not be published.