The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
weird file list problem jmmora AIX 8 08-08-2008 12:18 PM
Weird date difference problem meeraKh Shell Programming and Scripting 22 03-12-2008 11:50 PM
Weird crontab problem RobSand SUN Solaris 8 10-09-2007 06:12 PM
Weird problem with output from "date '+3600*%H+60*%M+%S' " m223464 Shell Programming and Scripting 5 02-16-2006 12:22 PM
weird problem with removing files rein UNIX for Advanced & Expert Users 2 08-15-2005 08:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-11-2003
danhodges99
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Weird Problem???

I have a problem I don't understand... I am trying to declare a variable, and then output the results of that variable, couldn't be simpler
Code:
#!/bin/ksh

VAR='Oranges'
if [ ${VAR}='Lemons' ]
  then
  echo "Found Lemons"
elif [ ${VAR}='Oranges' ]
  then
  echo "Found Oranges"
fi
The output shouold clearly be "Found Oranges", but it outputs "Found Lemons", or whatever is first in the if statement, it's doing my head in, please somebody help!

added code tags for readability --oombera

Last edited by oombera; 02-17-2004 at 03:30 PM..
  #2 (permalink)  
Old 04-11-2003
edog edog is offline
Registered User
  
 

Join Date: Sep 2001
Location: Green Bay, WI
Posts: 66
just add some space on each side of the = comparison:


#!/bin/ksh

VAR='Oranges'
if [ ${VAR} = 'Lemons' ]
then
echo "Found Lemons"
elif [ ${VAR} = 'Oranges' ]
then
echo "Found Oranges"
fi
  #3 (permalink)  
Old 04-11-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
edog is right, you need thoses spaces. For some insight to was happens without the spaces, see this post.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0