LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   If condition in script (http://www.linuxquestions.org/questions/red-hat-31/if-condition-in-script-190605/)

imsajjadali 06-07-2004 04:43 AM

If condition in script
 
How can I write the combined two conditon with and operator in script
my conditon is

if day-of-week equal to (=) monday and day-of-month is less then (<) 7 then
other programe statments.

how can I write this conditon in script? I have no knowledge to use less then and and operator.

thanks

if [ $DOW = "1" ] #Monday

Bebo 06-07-2004 06:22 AM

If you just get hold of the day of week and day of month in some way, then this would do:
Code:

if [ $DOW -eq 1 -a $DOM -lt 7 ] ; then
  blah
fi

To get more info on the tests, do man test.

imsajjadali 06-07-2004 06:28 AM

thanks
one thing more
which operator is used for less then equal to (<=)

Bebo 06-07-2004 06:35 AM

That would be -le; the corresponding "greater than or equal to" is -ge.

imsajjadali 06-07-2004 06:39 AM

thank you very much

Bebo 06-07-2004 06:52 AM

No problem :)


All times are GMT -5. The time now is 04:02 PM.