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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap