合并 A 和 B 并保留所有差异

问题描述

所以如果文件 A 是 1 2 3 4 和文件 B 是 1 2 3 4a 我希望输出是 1 2 3 4 4a 我可以在 KDIFF3 中手动执行此操作,但我想为所有 4000 多个差异自动执行此操作。

解决方法

也许将 GNU diff 与 If-then-else (const result = addAge(person); /* const result: IPerson & { age: number | null; } */ console.log(result.name.toUpperCase()); // "JUAN" console.log((result.age ?? 0).toFixed(2)); // "0.00" ) 一起使用,然后通过删除以下行来发布处理结果:

--ifdef=SIMPLE_MERGE

或使用行格式选项来定义您自己的要删除的文本。见#ifdef SIMPLE_MERGE #ifndef SIMPLE_MERGE #else /* SIMPLE_MERGE */ #endif /* SIMPLE_MERGE */ --old-line-format--new-line-format

,

我花了大约 3 个小时沿着不同的路径走下去。最终解决方案大约需要 5 分钟。

  1. 从位于以下位置的二进制文件下载 diff.exe http://gnuwin32.sourceforge.net/packages/diffutils.htm
  2. 重命名每个文件,以便于引用 A.lex B.lex
  3. 由于两个文件相同,我重命名了一组标记并添加了 -cy
  4. diff --text --ifdef=name a.lex b.lex > out2.txt

输出看起来像:

\_sh v3.0  724  English-Uzbek Dictionary

\lx ability
\cl N-05; related to: able
\cl J-09
\bk 5
\fr 4
\ph əbˈɪlɪti
\pd abilities
\ps noun
\sn 1
\sdw 09 cognition - nouns denoting cognitive processes and contents
\ss Sense 02: 03841132 ability,power - possession of the qualities (especially mental qualities) required to do something or get something done
\de a way to refer to the fact that you can do something
\xe The baby doesn't have the ability to hold her head up without help.
\xe I have confidence in my brother's ability to do the job.
#ifndef name
\du-cy бирор бир нарсани қила олишингизни англатиш йўли
\gu-cy қобилият
#else /* name */
\du biror bir narsani qila olishingizni anglatish yoʻli
\gu qobiliyat
#endif /* name */
\sn 2
\sdw 07 attribute - nouns denoting attributes of people and objects
\ss Sense 01: 03601639 ability - the quality of being able to perform; a quality that permits or facilitates achievement or accomplishment
\de the quality or skill that makes it possible for someone to do something successfully
\xe My friend's artistic ability is far greater than my own.
\xe The media has continually criticized his leadership abilities.
#ifndef name
\du-cy бирор бир нарсани яхши қилишга имконият берадиган фазилат ёки маҳорат
#else /* name */
\du biror bir narsani yaxshi qilishga imkoniyat beradigan fazilat yoki mahorat
#endif /* name */
\sn 3
\de a person's level of talent,skill or intelligence
\xe She is a student of average ability.
\xe There are doctors of all abilities at that hospital.
#ifndef name
\du-cy бирор бир кишининг маҳорати,қобилияти ёки ақл даражаси
#else /* name */
\du biror bir kishining mahorati,qobiliyati yoki aql darajasi
#endif /* name */
\sn 4
\se do something to the best of your ability
\de do something as well as you can
\xe Whatever you do,do it to the best of your ability.
#ifndef name
\du-cy бирор бир нарсани қўлингиздан келганича яхшироқ қилмоқ
#else /* name */
\du biror bir narsani qoʻlingizdan kelganicha yaxshiroq qilmoq
#endif /* name */

Do search and replace with nothing to remove unnecessary tags
#ifndef name
#else /* name */
#endif /* name */

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...