title: Getting "command not found" error in bash script
body: <p>I have written a bash script that gets three paths based on input parameters and then then gets the imagename/filename in the path.  </p>
  
  <p>Something like:<br>
  I provide:  </p>
  
  <pre><code>AA=/home/user
  </code></pre>
  
  <p>Then it uses the find command to get<br>
  /home/user/dir2/images/dir/tellmeimage1fun.bin  </p>
  
  <p>Finally I have to get tellmeimage1fun.bin as output.  </p>
  
  <p>Script:  </p>
  
  <pre><code>#!/bin/bash  
  
  echo "arg0 n/k/d"  
  
  AA=$1  
  CC=$3  
  
  PATH1="`find $AA/dir2/images/dir/ -name *image1*.bin`"  
  PATH2="`find $AA/dir2/images/dir/ -name *bimage2*.bin`"  
  PATH3="`find $AA/dir2/images/dir/ -name *cimage3*.bin`"  
  
  if [ $CC = "n" ] ; then  
      PATH=$PATH1  
  elif [ $CC = "k" ] ; then  
      PATH=$PATH2  
  else  
      PATH=$PATH3  
  fi  
  
  #Getting filename name from path:  
  IMG="`ls $PATH | cut -d "/" -f6`"
  
  OUTPUT:  
  /users/prasapat/bin/sl5: line 22: ls: command not found  
  /users/prasapat/bin/sl5: line 22: cut: command not found  
  </code></pre>
  
  <p>If I give complete paths to ls and cut they work. But i don't want to do that for all commands in the script.  If i remove the last line and echo the PATH variable it is completely fine. Only after adding the last command, I see the problem.  </p>
  
  <p>What am I doing wrongly?</p>