give me this error:
" file not found "
Here are the full code
#! /bin/bash
usage(){
echo " you need to provide an argument "
echo " usage : $0 file_ name "
}
is_file_exist(){
local file="$1"
[[ -f " $file " ]] && return 0 || return 1
}
[[ $# -eq 0 ]] && usage
if(is_file_exist "$1")
then
echo " file found "
else
echo " file not found "
fi
while the executing of a programe i get same output as file not found even if file are avaliable in directory.
why?
CodePudding user response:
I think your if
condition is invalid. It should be more like this
if [[ is_file_exist "$1" -eq 1 ]];then
echo "file found"
else
echo "file not found"
fi