*fixed if (( var1 && var2 )) ??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers *fixed if (( var1 && var2 )) ??
# 1  
Old 08-02-2005
if (( var1 && var2 )) ?? **fixed

*EDIT -- **FIXEd I must've done something wrong, because it works now..



I punched in "if" in the forum search but nothing came up, so I'm posting it here.

Quick question: Can someone correct my syntax.

Code:
#!/bin/ksh

if (( var >= 1 && var <= 5 )); then
...............................
fi

I'm trying to execute the commands within the if, only if a variable is in between two numbers (1-5)

Last edited by yongho; 08-02-2005 at 05:12 PM..
# 2  
Old 08-02-2005
Try this different syntax, I'm sure it works :

#!/bin/ksh
var=$1
if [ "${var}" -ge "1" -a "${var}" -le "5" ]
then
echo "YES"
fi


(launched with value in parameter => $1)
Rgds.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

2. Shell Programming and Scripting

Convert .../($var1|$var2)/... regex to string

Hello, In one part of my shell program I need to translate many of lines in the following pattern : /(folder1|...|folderN)/(sub1|...|subN)/.../(file1|...|fileN) into strings : /folder1/sub1/.../file1 /folder1/sub1/.../... /folder1/sub1/.../fileN ... /folderN/subN/.../fileN the... (2 Replies)
Discussion started by: Ghadamyari
2 Replies

3. Shell Programming and Scripting

replace & with &amp; xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

4. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

5. Shell Programming and Scripting

concatenate varaibles var1, var2 together to var1 again

HI i like to concatenate the two variables var1=$line (ie 22885068900000652 B86860003OLFXXX592123320081227) var2=$amount (ie 123456) i want to club together both the above varaible var1 & var2 and assign back to var1 right now i am doing like this but it is not working. var1=`echo... (1 Reply)
Discussion started by: kshuser
1 Replies

6. Shell Programming and Scripting

Fixed Width Join & Pad Sed/Awk Help

I was wondering someone might be able to push me in the right direction, I am writing a script to modify fixed-width spool files, As you can see below the original spool file broke a single line into two for printability sake. I have had been able do the joins using sed, the thing I am... (10 Replies)
Discussion started by: Cho Nagurai
10 Replies

7. UNIX for Dummies Questions & Answers

What is this? var2=${var1#??????????}

Googling the answer to this question just doesn't work when Google won't search your symbols for you. Can someone tell me what this command will assign to var2, and where I can find more information about using braces in this way? var2=${var1#??????????} Thanks so much. (2 Replies)
Discussion started by: blondie53403
2 Replies

8. Shell Programming and Scripting

(probably stupidly simple) if [ $var1 = $var2 ] problem...

OK, while I'm not new to the Mac or some of the the inner workings of Mac OS X I am quite new to scripting. And while I have "Learning the Bash Shell" by those lovely people at O'Reilly (Cameron Newham et. al.) I'm missing something, I just know I am. Here's the problem: At the beginning of... (2 Replies)
Discussion started by: woodgie
2 Replies

9. Shell Programming and Scripting

Echo var1,var2,var3,var4,var5,var6 in loop help

Hello, I have created numerous variables called $mask1 $mask2... $maskN. I wish to echo these variables, below is the code for the two functions, the first creates the variables and the second echos them. It is the second function which does not work. The line (i believe to be wrong) is in... (1 Reply)
Discussion started by: rorey_breaker
1 Replies
Login or Register to Ask a Question