title: Bash Scripting " [!: not found " errors, and how to write an or statement
body: <p>EDIT:
  Here is my updated code:</p>
  
  <pre><code>#!/bin/sh
  files=`ls`
  if [ $# -ne 1 -o -f $1 ]
  then
          echo "Usage: $0 &lt;directory&gt;"
          exit 1
  fi
  if [ ! -e $1 ]
  then
          echo "$1 not found"
          exit 1
  
  elif [ -d $1 ]
  then
  cd $1
  
  for f in $files
  do
          if [ ! -d "$f" ]
          then
             if [ ! -s "$f" ]
              then
                rm -r "$f"
          echo "File: $f was removed."
          else
          continue
          fi
  fi
  done
  
  
  echo "Name\t\tLinks\t\tOwner\t\tDate"
  
  for f in $files
          do
                  find "$f" -type f -printf "%f\t\t %n\t\t %u\t %TH %Tb %TY\n"
          done
          exit 0
  fi
  </code></pre>
  
  <p>I fixed all of the spacing issues, changed #!bin/sh to #/bin/bash, and added quotes to "$f". However I'm still getting lots of errors.</p>
  
  <blockquote>
    <p>ava@kosh:~/test$ ./delDir d1 rm:
    cannot remove <code>d1': No such file or
    directory File: d1 was removed. rm:
    cannot remove</code>delDir': No such file
    or directory File: delDir was removed.
    rm: cannot remove <code>delDir2': No such
    file or directory File: delDir2 was
    removed. rm: cannot remove</code>e1': No
    such file or directory File: e1 was
    removed. rm: cannot remove <code>e2': No
    such file or directory File: e2 was
    removed. rm: cannot remove</code>make_d1':
    No such file or directory File:
    make_d1 was removed.
    Name\t\tLinks\t\tOwner\t\tDate find:
    d1: No such file or directory find:
    delDir: No such file or directory
    find: delDir2: No such file or
    directory find: e1: No such file or
    directory find: e2: No such file or
    directory find: make_d1: No such file
    or directory ne1              2<br>
    ava       22 Nov 2009 ne2<br>
    2               ava       22 Nov 2009</p>
  </blockquote>
  
  <p>Does anyone know what else I'm doing wrong?</p>
  
  <blockquote>
    <p><s> Here's my code:</p>
  
  <pre><code>#!/bin/sh
  files=`ls`
  if [ $# -ne 1 ]
  then
          echo "Usage: $0 &lt;directory&gt;"
          exit 1
  fi
  if [ ! -e $1 ]
  then
          echo "$1 not found"
          exit 1
  
  elif [ -d $1 ]
  then
  cd $1
  
  for f in $files
  do
          if [! -d $f]
          then
             if [ ! -s $f ]
              then
                rm-r $f
          echo "File: $f was removed."
          else
          continue
          fi
  fi
  done
  
  
  echo "Name\t\tLinks\t\tOwner\t\tDate"
  
  for f in $files
          do
                  find $f -type f -printf "%f\t\t %n\t\t %u\t %TH %Tb %TY\n"
          done
          exit 0
  fi
  </code></pre>
    
    <p>Here are my questions:</p>
    
    <ol>
    <li><p>If I execute the script with something that is NOT an ordinary file
    AND  is NOT a directory I want it to
    say "Usage: Filename directory" (see
    line 5). I know I can do this with 2
    if statements but is it possible to
    create an or statement for this in
    bash?</p></li>
    <li><p>When I run the script I keep getting errors like this:</p></li>
    </ol>
    
    <blockquote>
      <p>./delDir: 39: [!: not found ./delDir: 39: [!: not found ./delDir:
      39: [!: not found ./delDir: 39: [!:
      not found ./delDir: 39: [!: not found
      ./delDir: 39: [!: not found ./delDir:
      39: [!: not found ./delDir: 39: [!:
      not found ./delDir: 39: [!: not found
      ./delDir: 39: [!: not found Name<br>
      Links           Owner           Date
      find: d1: No such file or directory
      find: delDir: No such file or
      directory find: delDir2: No such file
      or directory e1               1<br>
      ava       22 Nov 2009 e2<br>
      1               ava       22 Nov 2009
      find: make_d1: No such file or
      directory ne1              2<br>
      ava       22 Nov 2009 ne2<br>
      2               ava       22 Nov 2009</p>
    </blockquote>
    
    <p>I believe I am getting these errors
    because the for loop is first looking
    for the file that the user typed in
    (the directory it changed into) and
    cannot find it. How can if fix this?
    3. Are there any more errors you can see? </s></p>
  </blockquote>