|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
in my code if condition is not working. i am using array in the if condition the code: Code:
set -A rt 0 1 7 13 21
echo "Please enter a choice"
read choice;
for i in 0 1 2 3 4
do
if ['$choice' = ${rt[$i]}]
then
echo "something"
fi
doneLast edited by Scrutinizer; 07-08-2012 at 03:40 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
|
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Code:
if [ "$choice" = "${rt[$i]}" ]
then
echo "something"
fiThe single quotes wouldn't allow variable evaluation by the shell. Also, if you are doing string comparison, always try to enclose the operands in double-quotes. |
|
#4
|
|||
|
|||
|
Still the 'if condition' is not working
![]() |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
Try: Code:
rt=(0 1 7 13 21) |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
Thank you guys...
PiKK45 ... the link helped... It is working now... |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Great!!
![]() |
| Sponsored Links | ||
|
![]() |
| Tags |
| if condtion ksh |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Sorting file and get everything on same line on condition | brianjb | Shell Programming and Scripting | 0 | 06-05-2012 08:08 PM |
| [Solved] Delete files with condition | awadeid | UNIX for Dummies Questions & Answers | 5 | 05-31-2012 11:56 AM |
| redirect stdout echo command in condition A run in condition B | jao_madn | Shell Programming and Scripting | 3 | 11-02-2011 09:01 PM |
| Difference between [condition] and [[condition]] and ((condition)) when used with if condition | soumyabubun | HP-UX | 2 | 05-06-2011 01:03 PM |
| [solved] merging two files and writing to another file- solved | mlpathir | Shell Programming and Scripting | 1 | 10-07-2010 06:41 PM |
|
|