In this tutorial, you will learn how to check if a file exists on your system in a bash function. We are going to write a simple function in bash that will check if a file exists, and then display a message, if the file exists or not. Check if file exists For example, the code below will check if the file "owlhowto.txt" exists on the same path location with the bash script if [[ -f "owlhowto.txt" ]]; then echo " yes, owlhowto.txt exists" else echo " no, owlhowto.txt does not exist" fi