Linux Reader Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Is it possible to use “if 0” command?

Here you will find out:

  • why IF statements are
  • how you can change an unsuccessful status to successful
  • whether the bash command “if 0” works or not
  • when DiskInternals can help you

Are you ready? Let's read!

About IF statements

When writing a shell script, you sometimes want to initiate decisions or conditions, and to achieve this; you need to introduce the IF statement. The simplest syntax for a bash IF statement is:


The “CONDITIONS” are tests you wish to run and return “True” before the “COMMANDS” will run. However, if the "CONDITIONS" do not return "True", the "COMMANDS" will not run. Indeed, your commands will run only if the "CONDITIONS" return "True".

Note: Your “CONDITIONS” returning “True” simply means getting “0” (zero) as the response code. Any other response code besides “0” will cause your “COMMANDS” to not run.

How to change an unsuccessful status to successful

Since the IF statement requires that your conditions must return “True” (0) to run your “COMMANDS”, here’s how to manipulate the response code to print “0” regardless of whether the conditions were met or not.

Using the “!” operator, you can turn a successful test to print a nonzero number and vice versa.


By introducing the “!” operator, the return code will print “0” if the conditions are unsuccessful and print “1” if the conditions are successful.

Does the bash command “if 0” work?

Some people have asked if the bash command "if 0" works, and the simple answer to that question is explained below.


The example above will return an error response that reads: “…command not found”.

However, here’s the correct way to write the script:

This one will run successfully.

The initial error “…command not found” is due to the fact that “0” is not a command and IF expects to get return code from a command. "True" is a command, and "0" is not.

What will the “if 0” command execute?

This will tell IF to run a return code “0”, which is not a command. IF works for conditions and commands, not return codes. Commands include “true”, “false”, and “test”.

Get files from Linux easily

If you are working on a dual-boot PC that is booted to Windows, but you wish to access some important files from your Linux partition(s), the best and easiest way to achieve that is by using DiskInternals Linux Reader. DiskInternals Linux Reader is a free professional software utility that helps you to access files from Linux partitions while working on Windows. It is comprehensive software for dual-boot PC users and virtual machine users.

DiskInternals Linux Reader supports all Linux partitions and works very fast in loading all your Linux files. The interface is similar to the Windows File Explorer interface; thus, it is very easy to use. Also, DiskInternals Linux Reader supports FTP exports and quite a couple of other extensive features. Best of all, it is free to download.

FREE DOWNLOADVer 4.6, Win Upgrade to PROFrom $29.95