bash is file code example
Example 1: .sh script: check if file exist
#!/bin/bash
if [ -e x.txt ]
then
echo "ok"
else
echo "nok"
fi
Example 2: bash check for file
if test -f /bin/ls
then
echo "exists"
fi
Example 3: shell logical and for file existence
if [[ -f $FILE1 ]] && [[ -f $FILE2 ]]; then
echo "OK"
fi