LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs
User Name
Password

Notices


Old

If condition "if condition ... if condition"

Posted 08-28-2010 at 06:26 PM by the dsc (linux-related notes)
Updated 06-01-2023 at 12:47 PM by the dsc

If you want to have a script that would do something if either one of two consequences is true, a simple way to do that would be:

Code:
if [ condition 1 ] || [ condition 2 ] ; then
if [ condition 1 ] ; then
consequences for condition 1
fi
if [ condition 2 ] ; then
consequences for condition 2
fi
consequences of either one, but happens only once, not twice
fi
...
You check if either one is true, when "||"...
Member
Posted in Uncategorized
Views 1552 Comments 0 the dsc is offline

  



All times are GMT -5. The time now is 05:18 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration