-   Red Hat (
-   -   If condition in script (

imsajjadali 06-07-2004 05: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.


if [ $DOW = "1" ] #Monday

Bebo 06-07-2004 07:22 AM

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

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

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

imsajjadali 06-07-2004 07:28 AM

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

Bebo 06-07-2004 07:35 AM

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

imsajjadali 06-07-2004 07:39 AM

thank you very much

Bebo 06-07-2004 07:52 AM

No problem :)

All times are GMT -5. The time now is 07:54 PM.