Test if file/directory exists

#!/bin/bash
 
# Create a file
touch myfile.txt
 
# Create a directory
mkdir mydirectory
 
 
if [ -f myfile.txt ]
then
  echo "myfile.txt exists!"
fi
 
if [ -d mydirectory ]
then
  echo "mydirectory exists!"
fi