title: script to traverse through directories and subdirectories to list files
body: <pre><code>#!/bin/bash
  #script to loop through directories to merge files
  
  mydir=/data/
  files="/data/*"
  
  for f in $files
  do
      if[ -d "$f" ]
      then
              for ff in $f/*
              do
                      echo "Processing $ff"
              done
      else
              echo "Processing $f"
      fi
  done
  </code></pre>
  
  <p>I have the above code to go through directories and sub-directories and list all the files. I am getting the error: syntax error near unexpected token `then'</p>
  
  <p>What am I doing wrong here?</p>