Test operators
If -e test operator=file present or not in current directory
If -s test operator=file empty or not in current directory
If -d test operator=file is directory or not a directory
If -h test operator=file having symbolic links or not
If -r test operator=file is read permission or not
If -O test operator=file is owned by current user or not
#!/bin/bash
echo "check files is present in the current directory"
file=Test.txt
if [[-e $file ]];
then
echo " true file is present"
else
echo " file is not present"
fi
file="sample.txt"
if [[ -e $file ]]; then echo "true files is present"; else echo "false file is not present"; fi
If -s test operator
#############
$ if [[ -e $file ]]; then echo "file is not empty"; else echo "file is empty"; fi
if you want to check other directory as well you need to provide full path
file=subdire/sample.txt