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.

This can be achieved by the following shell script code. This code uses  if..else..fi 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

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com