IF condition doubt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting IF condition doubt
# 1  
Old 03-05-2008
IF condition doubt

Hi i found the following code in a date calculation script.

if ((!(year%100))); then
((!(year%400))) && leap=1
else
((!(year%4))) && leap=1
fi
I have not find such an use of if statement till now.
As for my knowledge this is the syntax of if statement

if [ condition_A ]
then
code to run if condition_A true
elif [ condition_B ]
then
code to run if condition_A false and condition_B true
fi

Can any one tell me how the above code works.


cheers
RRK
# 2  
Old 03-05-2008
That is ksh the (( .. )) construct: it is equivalent to let for arithmetic operations.

$(( .. )) lets you assign the result to a variable.

see man ksh for more information.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

For loop/while condition - doubt

hi., As we know that using for-loop or while condition, we can only process one by one sequentially, but , lets say this example : 1. under the folder "logs" there are 1000 files 2. each file has one record or line 3. have to perform atleast 7 queries per 3 seconds ,for instance ... (3 Replies)
Discussion started by: alnhk
3 Replies

2. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

3. Shell Programming and Scripting

Doubt..

Hi experts, In one of our code we have used some command like this. name=${name##*/} Can someone please let me know what exactly it does? Thanks & Regards, Sathya V. (1 Reply)
Discussion started by: Sathya83aa
1 Replies

4. Ubuntu

Doubt

hi ,, i am new for this.. i want to know abt linux os.. which version is best for it industry.. please suggest me..:cool: (1 Reply)
Discussion started by: c vignesh kumar
1 Replies

5. Red Hat

doubt

I need help in opening the .exe files in linux. As i have downloaded ubuntu os from trail version. after executing the the file name in terminal it is stating that get archive files for opening the .exe files. But i am unable to get it please help me (2 Replies)
Discussion started by: yashwanthguru
2 Replies

6. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

7. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

8. Shell Programming and Scripting

Doubt??

I jus want to know the meaning of the below command line(exclamation following that re-direction) sqlplus -s `cat /home/sample.txt` <<! Thanks!! (1 Reply)
Discussion started by: nohup
1 Replies

9. Shell Programming and Scripting

Condition test ( [[ ]] ) doubt

Hi , I have a doubt on condition test ( ] ). Pls refer blow program. #!/bin/ksh TEMP= if ;then echo $TEMP else print 'invalid option' fi Above script's TEMP variable has no value so it gives "invalid option" as output. But I got an error before priting the string . Result : ... (2 Replies)
Discussion started by: thambi
2 Replies
Login or Register to Ask a Question