I have a problem with a script in AIX, but I can't find the mistake. I want to copy files between two directories but checking first the existence of those directories. What I'm doing is this:
PATH=/home/fede/
PATH2=/home/prueba/
if [ -d $PATH ];
then
find $PATH -type f -exec cp {} $PATH2 \;
echo "se copiaron los archivos correctamente"
else
echo "no existe"
fi
But I receive this message: ./scriptTB[5]: find: not found. se copiaron los archivos correctamente
. The last line says "The files were copied correctly" in Spanish. The name of the script is scriptTB
.
Do I have to put anything before find
? It seems that the problem is in find
.
$PATH
is a default environment variable which tells your system where to find its program binaries (like thefind
program you are trying to use), so you should use a different name for that variable. I am betting that you are overwriting your system's$PATH
, and now your system cannot find thefind
program. Try this and see if it works.echo $PATH
.