Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You probably need to explain your requirements a bit more. However it's most likely you can do what you want with the diff command (with a little help from sort and/or grep).</p> <p>Let's assume you have two files: a.properties and b.properties</p> <p>If you simply want to know if the files are different in any way, you can use</p> <pre><code>diff a.properties b.properties </code></pre> <p>You'll get no output if they're identical or a list of differences.</p> <p>If you want a comparison on a more semantic level, that is, are the two sets of properties identical, then you need to do a bit more. The files can differ textually, but mean the same thing to Java programs that use them. For example, the properties can occur in a different order. There can be blank lines, other whitespace and comments.</p> <p>If this is the case, do you care if the comments are identical? They won't effect the operation of your program, but they have a meaning (and value to those reading the file). If you don't care, strip them out.</p> <p>You probably don't care about blank lines as they have no meaning.</p> <p>You also need to handle the following case:</p> <pre><code>a.properties: prop = value b.properties: prop=value </code></pre> <p>Again, different textually (note the spaces around the equals) but have the same meaning in Java.</p> <p>Starting simple, let's assume the properties occur in the same order.</p> <p>Ignore blank lines:</p> <pre><code>diff -B a.properties b.properties </code></pre> <p>Handle random white space (eg. around the equals sign)</p> <pre><code>diff -w a.properties b.properties </code></pre> <p>Combine all of this:</p> <pre><code>diff -w -B a.properties b.properties </code></pre> <p>Strip out comments:</p> <pre><code>grep -v '^#.*$' a.properties &gt; a.tmp grep -v '^#.*$' b.properties &gt; b.tmp diff -w -B a.tmp b.tmp rm a.tmp b.tmp </code></pre> <p>Allow for properties in a different order, strip comments:</p> <pre><code>grep -v '^#.*$' a.properties | sort &gt; a.tmp grep -v '^#.*$' b.properties | sort &gt; b.tmp diff -w -B a.tmp b.tmp rm a.tmp b.tmp </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload