Check if a file exists or not using Bash Script

Example:
#!/bin/bash

file_path="/Users/c2ctech/Desktop/data.csv"

if [ -e "$file_path" ]; then
    echo "The File data.csv exists."
else
    echo "The File data.csv does not exist."
fi
Output:

The File data.csv does not exist.

Check if a file exists or not using bash Script

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!