我正在尝试在我的bash脚本中创建一个实现locate命令的变量。该脚本始终表示该文件在不存在时存在,并且在文件存在时正常工作。
#!/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