title: awk statements - if not found (grep'ed) do
body: <p>My table file example looks like that  </p>
  
  <pre><code>Name1   xxxxx  34
  Name1   xxxxx  37
  Name2   aaaaa  59
  Name2   xxxxx  90
  Name4   Name3  12
  </code></pre>
  
  <p>Name file looks like that</p>
  
  <pre><code>Name1 
  Name2
  Name3
  Name4 
  </code></pre>
  
  <p>I want <code>awk</code> to match <code>Name1/2/3/4</code> from Name file to table file $1 and print sum of $3. <strong>If Name is not found print</strong> <code>0</code> - how can I do such <code>if</code> statement in <code>awk</code>?</p>
  
  <p>What I already done:  </p>
  
  <pre><code>for i in $(cat Name_file)
  do 
  cat table | awk -v NAME="$i" '($1==NAME) {SUM+=$3} END {print NAME"\t"SUM}'
  done
  </code></pre>
  
  <p>Gives output </p>
  
  <pre><code>Name1   71
  Name2   149
  Name3   
  Name4   12
  </code></pre>
  
  <p>It's almost perfect - I want to add <code>0</code> to <code>Name3</code> to get such output</p>
  
  <pre><code>Name1   71
  Name2   149
  Name3   0
  Name4   12
  </code></pre>
  
  <p>So much question is: How to add <code>if not found do</code> function in awk?</p>