Bash Shell scripting – Check if File Exists or Not

Bash Shell scripting - Check if File Exists or Not

In this post we will see how to write a bash shell script to Check if File Exists or Not.

Tech Tip : Did you know you can access all your windows application/games and data on Linux system itself with windows virtual desktop from with feature of remote accessibility from any device(PC/Mac/android/iOS). If you are a working professional then try out hosted SharePoint, Exchange and Office 365 from powered by Apps4Rent.

This can be achieved by the following shell script code. This code uses statement which allows us to make decisions based on the success or failure of a command.

In the shell script above we have used File test operators. -f $file_name expression in the above code returns True if file exists and is a regular file.

Following is the list of some other flags which we can use in File test operators.


Partner Sites