title: Bash script continue keyword not breaking loop iteration
body: <p>I am following a series of tutorials to learn Bash shell script. One of the exercises is to loop through files in the current directory and search for a pattern in those files. If the pattern is found then the script should sum the file size of those files.</p>
  
  <pre><code>#!/bin/sh
  patern=echo
  totalSize=0
  
  for file in * 
  do
      [ ! -f $file ] &amp;&amp; continue  
  
      if grep $patern $file &gt; /dev/null
      then    
          echo "pattern matched in $file" 
          echo "file size is `stat -c%s $file`"
          fileSize=`stat -c%s $file`
  
          totalSize=`expr $totalSize + $fileSize`
          echo "size so far is $totalSize bytes"
          echo                                                    
      fi
  done
  </code></pre>
  
  <p>I have one other folder in the directory from which I am running the script. The folder is called "somedir". It is empty. I have took a snippet of output text pasted below. The middle 3 lines show when the loop iterates over the directory "somedir" which it prints as "sum_files"- my script name along with a file size. </p>
  
  <p>I don't understand this behaviour. How can an empty directory have a file size? <br>
  But my main concern is as to why the continue keyword is not stopping the loop iteration. The output is showing that the script is running the below if statement containing the grep command even though it should stop if a directory is found. <br><br>I have verified that the test command<code>[ ! -f $file ]</code> does in fact return 0 when the loop gets to the directory and thus the <code>&amp;&amp; continue</code> should be invoked. So why does the program continue with the rest of the loop code and try to grep the directory rather than just skipping the loop iteration at continue as expected? I know this is rather trivial but would like to know what's going on here.</p>
  
  <h2>Output text</h2>
  
  <p>pattern matched in retirement<br>
  file size is 396<br>
  size so far is 6385 bytes<br></p>
  
  <p>pattern matched in sum_files<br>
  file size is 398<br>
  size so far is 6783 bytes<br></p>
  
  <p>pattern matched in tp0<br>
  file size is 164<br>
  size so far is 6947 bytes<br></p>