IF

Posted On 2007-05-01 by FortyPoundHead
Keywords: Command Reference
Tags: Linux Commandline Linux
Views: 1495


Conditionally perform a command.

SYNTAX
if test-commands; then
consequent-commands;
[elif more-test-commands; then
more-consequents;]
[else alternate-consequents;]
fiThe test-commands list is executed, and if its return status is zero, the consequent-commands list is executed.

If test-commands returns a non-zero status, each elif list is executed in turn, and if its exit status is zero, the corresponding more-consequents is executed and the command completes.

If `else alternate-consequents'' is present, and the final command in the final if or elif clause has a non-zero exit status, then alternate-consequents is executed.

The return status is the exit status of the last command executed, or zero if no condition tested true.


About the Author

FortyPoundHead has posted a total of 1974 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.156.37.174

Before you can post, you need to prove you are human. If you log in, this test goes away.




Code Links