Sponsored Content
Top Forums Shell Programming and Scripting problem in string comparison in shell programming Post 302292419 by cfajohnson on Friday 27th of February 2009 09:02:54 PM
Old 02-27-2009
Quote:
Originally Posted by fpmurphy
Not necessarily true. It will result in an unsatisfactory ordering for certain locales unless the correct collator (for the locale) is provided in the underlying OS to allow locale-sensitive ordering. Bash and other shells do not include built-in collators.

Some shells such as ksh93 and zsh specifically avoid the issue for this reason. From the ksh93 man page

The zsh manual has almost identical text.

The bash manual states, "lexicographically in the current locale", but in fact uses the character's ASCII value.

The shell does use the locale's collating order for character ranges, e.g., [a-z]. I don't know whether the order is generated by the shell or by the OS.
 

10 More Discussions You Might Find Interesting

1. Programming

Unix Programming Book Comparison

Hi, I am starting out to program on Unix, having had experience in C and C++ in DOS. I would like to know, of these three, which is the best book for learning C programming in Unix: Advanced Unix Programming by Marc Rochkind Advanced Unix Programming by Warren Gay Advanced Programming in... (6 Replies)
Discussion started by: theicarusagenda
6 Replies

2. Shell Programming and Scripting

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (3 Replies)
Discussion started by: amarnath
3 Replies

3. AIX

Problem in ksh script ( String comparison )

hi , i am trying to compre two strings if ] or if ] when the length of var1 is small (around 300-400 char ) it works fine but when it is large (around 900-1000 chars) it fails is there any limitations for this type of comparison ??? (1 Reply)
Discussion started by: amarnath
1 Replies

4. Shell Programming and Scripting

bash shell script string comparison

I want to remove a line that has empty string at second field when I use cut with delimeter , like below $cat demo hello, mum hello, #!/bin/sh while read line do if then # remove the current line command goes here fi done < "demo" i got an error message for above... (4 Replies)
Discussion started by: bonosungho
4 Replies

5. Solaris

String Comparison in Shell script

I Have a script which gets the status of oracle database and if the status is READ WRITE ..it should echo "db is up " else "db is down" Here is the code if then echo "db up" else echo "db down" fi done; The script is giving me out put "db down" even thoug the value of... (6 Replies)
Discussion started by: njafri
6 Replies

6. Shell Programming and Scripting

Arithmetic Problem with shell script programming.

Hello everybody, I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input. I... (1 Reply)
Discussion started by: Florinel76
1 Replies

7. Homework & Coursework Questions

Arithmetic Problem with shell script programming.

Hello everybody, I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input. I... (8 Replies)
Discussion started by: Florinel76
8 Replies

8. Shell Programming and Scripting

String comparison problem

Hi, can someone please help me!!! urgent! I have a strange issue here. I grep for 2 strings from a txt files and compare the string value. Though the string values are the same, they are compared as different values. Please help Case-1 -------- Here I grep for 2 different field values... (3 Replies)
Discussion started by: vani123
3 Replies

9. Shell Programming and Scripting

Problem in string comparison

guys , i am using inotify for monitoring one directory to check core file generation , my snippet of code is follows #!/bin/bash DIR=$1 inotifywait -q -e create -m $DIR | while read path events name; do if ]; then echo "Now I am going to do something with $name in directory $path."... (5 Replies)
Discussion started by: baker
5 Replies

10. Shell Programming and Scripting

awk string comparison unterminated quoted string andrule of thumb

I have the logic below to look up for matches within the columns between the two files with awk. In the if statement is where the string comparison is attempted with == The issue seems to be with the operands, as 1. when " '${SECTOR}' " -- double quote followed by single quote -- awk matches... (1 Reply)
Discussion started by: deadyetagain
1 Replies
COLLATOR.__CONSTRUCT(3) 						 1						   COLLATOR.__CONSTRUCT(3)

Collator::__construct - Create a collator

SYNOPSIS
public Collator::__construct (string $locale) DESCRIPTION
Creates a new instance of Collator. PARAMETERS
o $locale - The locale whose collation rules should be used. Special values for locales can be passed in - if null is passed for the locale, the default locale's collation rules will be used. If "root" is passed, UCA rules will be used. The Locale attribute is typically the most important attribute for correct sorting and matching, according to the user expectations in different countries and regions. The default UCA ordering will only sort a few languages such as Dutch and Portuguese correctly ("correctly" meaning according to the normal expectations for users of the languages). Otherwise, you need to supply the locale to UCA in order to properly collate text for a given language. Thus a locale needs to be supplied so as to choose a collator that is correctly tai- lored for that locale. The choice of a locale will automatically preset the values for all of the attributes to something that is reasonable for that locale. Thus most of the time the other attributes do not need to be explicitly set. In some cases, the choice of locale will make a difference in string comparison performance and/or sort key length. RETURN VALUES
Returns Collator instance. ERRORS
/EXCEPTIONS Returns an "empty" object on error. You can use intl_get_error_code(3) and/or intl_get_error_message(3) to know what happened. EXAMPLES
Example #1 Collator.__construct(3) example <?php $coll = new Collator( 'en_CA' ); ?> SEE ALSO
Collator.create(3), collator_create(3). PHP Documentation Group COLLATOR.__CONSTRUCT(3)
All times are GMT -4. The time now is 08:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy