0

what is the wrong?

#!/usr/local/bin/bash

REF_FILE_NUM="000000010000001900000052"

for id in `ls -1 dir` ;
 do
 FILE_NUM=${id:0:24}
 echo "FILE_NUM: $FILE_NUM ; REF_FILE_NUM: $REF_FILE_NUM"

 if [[ "$FILE_NUM" < "$REF_FILE_NUM" ]]
 then
    echo "$FILE_NUM lt $REF_FILE_NUM"
    echo ""
 else
    echo "$FILE_NUM gt $REF_FILE_NUM"
    echo ""
 fi

 done
freebsd# ./test.sh
FILE_NUM: 0000000100000019000000FF ; REF_FILE_NUM: 000000010000001900000052
0000000100000019000000FF gt 000000010000001900000052

FILE_NUM: 0000000100000020000000FF ; REF_FILE_NUM: 000000010000001900000052
0000000100000020000000FF gt 000000010000001900000052

FILE_NUM: 0000000100000021000000FF ; REF_FILE_NUM: 000000010000001900000052
0000000100000021000000FF gt 000000010000001900000052

closed as off-topic by muru, Jeff Schaller Aug 1 at 20:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller
If this question can be reworded to fit the rules in the help center, please edit the question.

  • I fail to see the point FF ending values are greater then 52 ending one. – Archemar Jul 19 at 14:27
  • 2
    Indeed; what is wrong? It looks OK to me. 20 and 21are greater than 19. (1) Please explain what the script is supposed to be doing. (2) Please tell us what your filenames are. (Do this explicitly, separately from the output of your script.) (3) Explain what output you expect, and why. (4) Explain why you believe that the actual output is wrong. (5) Your filenames have a lot of zeroes in them, and are hard to read. Repeat your test with short names like 11952, 119FF, 120FF and 121FF. … Please do not respond in comments; edit your question to make it clearer and more complete. – Scott Jul 19 at 14:28
  • I apologize to everyone, the script is really OK, but I was a little tired yesterday and slip up. Thank you all. – Anar Jul 20 at 8:27
1

That all boils down to

[[ F > 5 ]] && [[ 2 > 1 ]]

In ASCII, F is 70 (0x46), while 5 is 53 (0x35).

What output would you expect and why?

Not the answer you're looking for? Browse other questions tagged or ask your own question.