$ cmp -s file1 file2, this command doesn't return anything for the following cases: case 1: both files are different; case 2: both files are same [closed]

Clash Royale CLAN TAG#URR8PPP
up vote
-1
down vote
favorite
$ cmp -s file1 file2
The above command doesn't return anything for the following cases:
- Case 1: both files (file1 and file2) are different;
- Case 2: both files (file1 and file2) are same.
I tried all the above cases, but my unix system is insensitive.
files file-comparison
closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
add a comment |Â
up vote
-1
down vote
favorite
$ cmp -s file1 file2
The above command doesn't return anything for the following cases:
- Case 1: both files (file1 and file2) are different;
- Case 2: both files (file1 and file2) are same.
I tried all the above cases, but my unix system is insensitive.
files file-comparison
closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
add a comment |Â
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
$ cmp -s file1 file2
The above command doesn't return anything for the following cases:
- Case 1: both files (file1 and file2) are different;
- Case 2: both files (file1 and file2) are same.
I tried all the above cases, but my unix system is insensitive.
files file-comparison
$ cmp -s file1 file2
The above command doesn't return anything for the following cases:
- Case 1: both files (file1 and file2) are different;
- Case 2: both files (file1 and file2) are same.
I tried all the above cases, but my unix system is insensitive.
files file-comparison
files file-comparison
edited Aug 10 at 17:30
Stéphane Chazelas
284k53524862
284k53524862
asked Aug 10 at 17:18
Gopinath Pushpa Thirunavukaras
164
164
closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
closed as off-topic by DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM Aug 11 at 9:31
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." â DopeGhoti, Thomas Dickey, Thomas, msp9011, telcoM
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
4
down vote
-s is for silent, it's to tell cmp not to output anythingù but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:
if cmp -s file1 file2; then
echo same
else
echo differ or error
fi
Or:
cmp -s file1 file2 && rm file2
If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.
ù except with some implementations for error messages when files can't be opened, not when they differ.
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
add a comment |Â
up vote
1
down vote
I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
-s is for silent, it's to tell cmp not to output anythingù but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:
if cmp -s file1 file2; then
echo same
else
echo differ or error
fi
Or:
cmp -s file1 file2 && rm file2
If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.
ù except with some implementations for error messages when files can't be opened, not when they differ.
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
add a comment |Â
up vote
4
down vote
-s is for silent, it's to tell cmp not to output anythingù but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:
if cmp -s file1 file2; then
echo same
else
echo differ or error
fi
Or:
cmp -s file1 file2 && rm file2
If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.
ù except with some implementations for error messages when files can't be opened, not when they differ.
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
add a comment |Â
up vote
4
down vote
up vote
4
down vote
-s is for silent, it's to tell cmp not to output anythingù but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:
if cmp -s file1 file2; then
echo same
else
echo differ or error
fi
Or:
cmp -s file1 file2 && rm file2
If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.
ù except with some implementations for error messages when files can't be opened, not when they differ.
-s is for silent, it's to tell cmp not to output anythingù but only to reflect whether the files are identical or not in its exit status so that it can be used for instance in an if shell statement:
if cmp -s file1 file2; then
echo same
else
echo differ or error
fi
Or:
cmp -s file1 file2 && rm file2
If you want it to output something, remove the -s. Then cmp will output a message when the files differ stating where they start to differ.
ù except with some implementations for error messages when files can't be opened, not when they differ.
edited Aug 10 at 17:33
answered Aug 10 at 17:28
Stéphane Chazelas
284k53524862
284k53524862
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
add a comment |Â
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
I got understood. I am new to Unix, I never went to shell programming learning till now. Thanks.
â Gopinath Pushpa Thirunavukaras
Aug 10 at 17:35
add a comment |Â
up vote
1
down vote
I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?
add a comment |Â
up vote
1
down vote
I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?
add a comment |Â
up vote
1
down vote
up vote
1
down vote
I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?
I would question your case 1. If cmp doesn't return anything then the files likely are identical. Try diff file1 file and sum file1 file2 to confirm. Is it possible that the differences are in non-printable characters?
answered Aug 10 at 17:29
Doug O'Neal
2,6271716
2,6271716
add a comment |Â
add a comment |Â