LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 06-07-2004, 04:43 AM   #1
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Rep: Reputation: 15
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
 
Old 06-07-2004, 06:22 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
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.
 
Old 06-07-2004, 06:28 AM   #3
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Original Poster
Rep: Reputation: 15
thanks
one thing more
which operator is used for less then equal to (<=)
 
Old 06-07-2004, 06:35 AM   #4
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
That would be -le; the corresponding "greater than or equal to" is -ge.
 
Old 06-07-2004, 06:39 AM   #5
imsajjadali
Member
 
Registered: Jan 2004
Location: Faisalabad-Pakistan
Distribution: Red Hat Linux 2.1 Advance Server
Posts: 102

Original Poster
Rep: Reputation: 15
thank you very much
 
Old 06-07-2004, 06:52 AM   #6
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 31
No problem
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Silly error: If test condition shalomajay Programming 3 10-31-2005 03:57 PM
cedega and CS: condition zero bojann Linux - Games 8 06-27-2005 01:49 PM
What condition I don't need initrd? Chowroc Linux - General 3 05-22-2005 02:59 AM
simple if condition sonesay Programming 10 05-21-2004 10:34 PM
CounterSrike: Condition Zero Comarez Linux - Games 2 04-20-2004 02:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 06:30 AM.

Main Menu
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