Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Does the variable <code>$i</code> contain the value <code>profile$</code>? I'm going to assume that it does.</p> <p>A dollar at the end of the word is tricky. Without the variable, you could write:</p> <pre><code> Bool=$(grep '^profile\$' File1) </code></pre> <p>With the variable, we need a trick to suppress the meaning of <code>$</code> as a metacharacter:</p> <pre><code>Bool=$(grep "^$i.*" File1) </code></pre> <p>(Note that it is far better to use <code>$(...)</code> than the equivalent with back-ticks, aka back-quotes.)</p> <p>Also, of course, if you want the whole line to be exactly <code>profile</code>, then there's no need for special tricks:</p> <pre><code>Bool=$(grep "^$i" File1) </code></pre> <p>should work fine.</p> <hr> <h3>Dealing with the Creature Feep in the Question</h3> <pre><code>while read -r i do Bool=$(grep "^$i.*" File1) if [ -z "$Bool" ] then echo " $i Not Available" fi done &lt; File2 </code></pre> <p>The <code>-r</code> suppresses some expansions that you might otherwise suffer from. If your shell doesn't like it, drop it; you'll usually be OK without it.</p> <hr> <h3>Another way to do it</h3> <p>If you are looking for missing lines and order is not important, then you could sort both <code>File1</code> and <code>File2</code> and then use <a href="http://pubs.opengroup.org/onlinepubs/9699919799/utilities/comm.html" rel="nofollow"><code>comm</code></a> to compare them, getting the entries that are in <code>File2</code> but not in <code>File1</code>. If you've got <code>bash</code> and 'process substitution' available, then:</p> <pre><code>comm -13 &lt;(sort File1) &lt;(sort File2) </code></pre> <p>If you don't have process substitution, then:</p> <pre><code>sort -o File1 File1 sort -o File2 File2 comm -13 File1 File2 </code></pre>
 

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