0

I am trying to create a variable in my bash script implementing the locate command. The script always gives says that the file exists when it does not exist and works like normal when the file does exist.

#!/bin/bash
    ##tests if the file "googlesamples-assistant exists" and creates the variable googlesamples_assistant

    googlesamples_assistant=$(locate -n 1 /env/bin/googlesamples-assistant)

    ##if the file googlesamples_assistant is found then run this

        if [ -f $googlesamples_assistant ]
            then 
                echo "found"
    ##if the file googlesamples_assistant is not found then run this

            else
                echo "not found"

        fi
Vanish
  • 51
  • 1
  • 5

0 Answers0