Riddle - solve it if you can


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Riddle - solve it if you can
# 1  
Old 08-15-2007
Riddle - solve it if you can

I don't understand this, can anyone explain the evaluation logic used here, and I would really appreciate a general explanation for it.
----------------------
Here's the korn script:
--------------------
#! /usr/bin/ksh
if [[ 2 > 10 ]]
then
echo true
else
echo false
fi

if (( 2 > 10 ))
then
echo true
else
echo false
fi
-------------------
And the output is:
------------------
true
false

Why is the output like that? How is 10 > 2 even when evaluated as a string (giving me true)?

Thanks!
# 2  
Old 08-15-2007
ASCII hex value of '1'- 31
ASCII hex value of '2'- 32

when compaired 'as strings': 32 > 31
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

please help me to solve it

i thought about to use the commands : wc and sort cut and mybe more .. i need to write a bash script that recive a list of varuables kaka pele ronaldo beckham zidane messi rivaldo gerrard platini i need the program to print the longest word of the list. word in the output appears on a... (0 Replies)
Discussion started by: yairpg
0 Replies

2. UNIX for Dummies Questions & Answers

Output from who command - quick riddle

Hi all. So I have a problem. I have been doing real good figuring this stuff out on my own but Im a newbie and stuck on something that is probably real basic. I want to get the following output from the who command: User TTY Date Time gd22a12 pts/1 Feb 1 11:34 gd22a13 pts/3 Feb 1... (13 Replies)
Discussion started by: losingit
13 Replies

3. Shell Programming and Scripting

Ksh riddle: interpret variable two times?

exam is a ksh script. In command line I enter: exam 3 param_2 param_3 param_4. In exam how can I get the value of the parameter which position is specified by the first argument. Simply doing this DOES NOT work: offset=$1 value=$$offset can you figure out any possible way to interpret a... (5 Replies)
Discussion started by: i27oak
5 Replies

4. UNIX for Dummies Questions & Answers

Can somebody solve this

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (13 Replies)
Discussion started by: sreenusola
13 Replies

5. UNIX for Advanced & Expert Users

Can somebody solve this

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (1 Reply)
Discussion started by: sreenusola
1 Replies

6. Shell Programming and Scripting

Can somebody solve this please

I have to find the files older than 200 days from a path and copy them to some other directory with the current date stamp attached to it. i have written like follows: #!/bin/ksh DSTAMP=$(date +"%y%m%d%H%M") rm $CA_OUT_PATH/ftp_logs/temp touch $CA_OUT_PATH/ftp_logs/temp chmod 777... (1 Reply)
Discussion started by: sreenusola
1 Replies

7. Programming

does any one know how to solve?

Hello experts, Here is my code.I can create the database.But I also want it to see standard output.Please see the blocked code.If i use them they show me weired symbols. #include <stdio.h> #include <stdlib.h> struct date { int month; int day; int year; }; struct empRec{... (14 Replies)
Discussion started by: mlhazan
14 Replies

8. Shell Programming and Scripting

How to solve this

I have to write an script for.. CUST: 123 trans: some contents CUST: 1234 trans: some contents Now wat i have to do is this: CUST:123 akash trans: some contents CUST:1234 akash1 trans: I have been able to add... (3 Replies)
Discussion started by: akashag22
3 Replies
Login or Register to Ask a Question