![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [sh] String comparison operators | userix | Shell Programming and Scripting | 1 | 05-16-2008 01:09 AM |
| string comparison | Jatsui | Shell Programming and Scripting | 5 | 02-04-2008 01:28 PM |
| string comparison | fedora | Shell Programming and Scripting | 2 | 01-03-2007 12:20 PM |
| Get Comparison operators from with RexExp | umen | Shell Programming and Scripting | 3 | 07-19-2006 07:38 AM |
| String Comparison | abey | High Level Programming | 1 | 10-19-2005 09:08 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#8
|
||||
|
||||
|
Quote:
Code:
#! /bin/sh
read A B
if [[ $A < $B ]] ; then
echo "$A is less than $B"
else
echo "$A is greater than $B"
fi
exit 0
|
| Forum Sponsor | ||
|
|
|
#9
|
|||
|
|||
|
i tried the other one too with the double brackets and it doesnt give me the right result. it does show an error but will go through the whole execution of the program, but as mentioned before, the result isn't correct
this is what happens intranet (121) % sh strcmp.sh hi bye strcmp.sh: [[: not found hi is greater than bye intranet (122) % sh strcmp.sh bye hi strcmp.sh: [[: not found bye is greater than hi so in the first run, i type in hi and bye, it says the [[ part of the code not found...i take it that it cant interpret double brackets. and it goes to the else statement. in the second run i type in bye before hi, and it goes to the else statement again, while it should've been the first if statement. i'm going to have to try it out on a real c shell to see what the result turns out to be. |
|
#10
|
||||
|
||||
|
I guess it must have something to do with the vmware machine.
|
|
#11
|
|||
|
|||
|
i'mnot using it with vmware at the moment, but i'm using SPARC, i think it's based on unix, hence why it keeps interpreting the > and < as redirect. however the double brackets arent working either. i found another forum where a user had posted his code which looks just like the one with the double brackets and he's having the same problem.
i will have to test both codes tomorrow on my school's vmware. |
|
#12
|
|||
|
|||
|
hi, vino, i just wanted to say thanks for your help. i d/led cygwin and ran the code for the double brackets and it works like a charm. i think cygwin is a c shell emulator? or perhaps bourne shell. either way it's working great.
|
|||
| Google The UNIX and Linux Forums |