0

I wrote the below small shell script. However when i run it am getting the error ctrlM_chk_input_file.sh[5]: find: not found but I thought the backtics will make the find statement to be run as a unix command. Am I missing something?

PATH="/main/nedcor/flexcube"

cd $PATH
'pwd'
DIR_LIST=`find . -name "INPUT"`

for INPUT_PATH in $DIR_LIST

do
    RESULT=`ls -A $INPUT_PATH | grep -v BKUP`
    echo $RESULT 
    if [ -z $RESULT ] ;
    then 
        echo "No Files found"
        exit 0
    else
        echo file $RESULT found
        exit 1
    fi
done
  • 2
    As Eric already explained, the issue is that you're changing the system variable, PATH. This is why you should always avoid using UPPER CASE variable names in shell scripting. – terdon Apr 29 '15 at 16:37
6

PATH is a "magic" variable that tells the shell where to find executables. You changed that to just your directory, which does not have a find executable.

If you use a different name it should work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.