Questions tagged [cmp]

cmp is a command line utility for computer systems that use Unix or a Unix-like operating system.It compares two files of any type and writes the results to the standard output

By default, cmp is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported.

Return values:

0 —> files are identical
1 —> files differ
2 —> inaccessible or missing argument

Read more

150 questions
5
votes
2 answers

cmp command returning EOF on my output despite exact match as far as i can tell

So I will start by saying this is for a course and I assume the professor won't really care that they are the same if cmp returns something weird. I am attempting to compare the output of my code, named uout, to the correct output, in the file…
user2763113
  • 63
  • 1
  • 2
  • 6
5
votes
1 answer

compare binary files and print only offset of matching line

For regular files I can use the comm command to find common lines. For example we have two files $ cat f1 line1 line2 line3 line4 line5 $ cat f2 line1 line20 line30 line4 line5 Its compared like: $ comm -12 f1 f2 line1 line4 line5 How to find…
webminal.org
  • 44,948
  • 37
  • 94
  • 125
4
votes
1 answer

Adsense is showing IAB TCF error 3.3 detected message

We're using Adsense and enabled Privacy and Messaging settings, GPDR, CCPA a long time ago. But suddenly started seeing an error on Adsense, TCF Error 3.3 Waited a couple months but still getting new errors. We're not using any SDK but simply…
Sam Salim
  • 2,145
  • 22
  • 18
4
votes
2 answers

Why take CMP ECX, ECX?

I am looking through some assembly and I see the line CMP ECX, ECX Which doesn't make sense to me, because isn't it always true A==A? (Reflexive property) Not sure if this will help, but it is used in this context: CPU Disasm Address Hex dump …
user2059300
  • 361
  • 1
  • 5
  • 17
4
votes
2 answers

How to get values used by cmp in assembly language with gdb?

I have a program comparing two values and I would like to print them for debug : 0x00000000004005cd <+73>: mov DWORD PTR [rbp-0x4],eax 0x00000000004005d0 <+76>: mov eax,DWORD PTR [rbp-0x4] => 0x00000000004005d3 <+79>: cmp …
mimipc
  • 1,354
  • 2
  • 14
  • 28
4
votes
1 answer

cmp assembly language instruction - gas format

I am converting 32-bit and 64-bit assembly language files from gas to MASM format, and ran across an instruction in my code that seems completely problematic. What I mean is, I see no way the assembler can know what size the operand is, whether the…
honestann
  • 1,374
  • 12
  • 19
3
votes
2 answers

Infinite loop when using cmpq and je

I'm decrementing RAX on each iteration. If RAX is zero, the program should change flow. # AT&T syntax start_calc_factorial: decq %rax cmpq $0, %rax je quit_calc_factorial mulq %rcx jmp start_calc_factorial However, the program never…
Dutchman
  • 180
  • 7
3
votes
4 answers

Compare two lines in same file

Given a file like the following:- 01/09/2005 02/09/2005 03/09/2006 03/09/2006 I wish to compare if the last two lines are the same, and return a 1 if so or a 0 if they are not. I can get the last two using a cat tail -2
general exception
  • 4,202
  • 9
  • 54
  • 82
3
votes
2 answers

Print file without adding trailing newline with awk

I'm using awk to process some program files, removing debugging sections. Some of these files have no trailing newline. I'd like to have awk print the file line by line, with newlines, but without adding an extra newline at the end if it's not…
Chris Middleton
  • 5,654
  • 5
  • 31
  • 68
3
votes
3 answers

sort with lexicographic order

I see the results from the following code, but I don't understand exactly how the or knows what to do in the following sort example: use Data::Dumper; $animals{'man'}{'name'} = 'paul'; $animals{'man'}{'legs'} = 2; $animals{'cheeta'}{'name'} =…
mleykamp
  • 1,356
  • 2
  • 9
  • 11
2
votes
1 answer

x86 cmp Opcode, Pointers and Inline Literals

I am using gdb to examine a program. In assembly, the code is doing: cmp $0x5, %eax However, when I examine the contents of %eax, I get: \020\343\377\377\377\177 when examined as a string. How is \020\343\377\377\377\177 compared to $0x5 in…
darksky
  • 20,411
  • 61
  • 165
  • 254
2
votes
1 answer

strange behavior of x86 "cmp" instruction

Here is the code: #include #include using namespace std; #define ARR_LENGTH 1000000 #define TEST_NUM 0 typedef unsigned int uint; uint arr[ARR_LENGTH]; uint inc_time(uint x) { uint y = 0, tm = clock(); for (uint i =…
n0p
  • 713
  • 10
  • 23
2
votes
1 answer

How to ignore output of diff in bash

I tried to compare two files and output customized string. Following is my script. #!/bin/bash ./${1} > tmp if ! diff -q tmp ans.txt &>/dev/null; then >&2 echo "different" else >&2 echo "same" fi When I execute script, I get: sh cmp.sh…
Steven
  • 811
  • 4
  • 23
2
votes
1 answer

bisect and lists of user defined objects (python 3)

Before python 3, I used bisect to insert user-defined objects into a list. bisect was happy with this because my user-defined object had a def __cmp__ that defined how to compare the objects. I've read the rationale for not supporting cmp in…
Mike
  • 71
  • 3
2
votes
1 answer

Comparing integer values in assembly

We are tasked to do compare integer values and print out appropriate prompt to show which values are greater. The code I made below initializes 'i' and 'j' to 5 and 4, respectively. The objective is to compare "variables" instead of the immediate…
sadness uee
  • 21
  • 1
  • 4
1
2
3
9 10