0

how to compare two text file by ignoring the command " // Q_L1_M1F0" on second text file.

1.Text File

REG= 0x3e23, 0x0110
REG= 0x5d2w, 0x69E9
REG= 0x3e23, 0x7051
REG= 0x3s06, 0xB190
REG= 0x3e23, 0x5694
REG= 0x3e2f, 0x0130
  1. text file ,
REG= 0x3e23, 0x0110     //  Q_L1_M1F0
REG= 0x5d2w, 0x69E9     //  Q_L1_M0F3
REG= 0x3e23, 0x7051     //  Q_L1_M4F0
REG= 0x3s06, 0xB190     //  Q_L1_M0F6
REG= 0x3e23, 0x5694     //  Q_L1_M7F0
REG= 0x3e2f, 0x0130     //  Q_L1_M2F6
Math2101
  • 11
  • 2
  • So your actual question is "How can I strip C end line comments from a string"? – Jabberwocky May 20 '20 at 14:01
  • @Jabberwocky: yes – Math2101 May 20 '20 at 14:06
  • The I'd [edit] the the question accordingly. The less irrelevant information is in the, the more likely people will answer. – Jabberwocky May 20 '20 at 14:08
  • 1
    That's basic C string manipulation. Find the index of the last occurrence of `//`in the string. Put a NUL in the string at that index. Then strip the remaining spaces from the end of the string. – Jabberwocky May 20 '20 at 14:10
  • @user3121023 we don't know if the `//` comment is always in the same position. – Jabberwocky May 20 '20 at 14:11
  • the command and the space remains the same for all the lines. once i try to remove the command line i will use strcmp to compare the text. Could you say me which function to remove " // Q_L1_M2F4" ? – Math2101 May 20 '20 at 14:16
  • With shell: `diff -u <(sed -e 's:[ \t]*\(//.*\)*$::' file1) <(sed -e 's:[ \t]*\(//.*\)*$::' file2)` – zwol May 20 '20 at 14:21

0 Answers0