Sponsored Content
Top Forums Shell Programming and Scripting Unexpected results with lists in GNU sed Post 302607847 by Scrutinizer on Thursday 15th of March 2012 01:03:16 PM
Old 03-15-2012
I was thinking this might be a locale issue, therefore I suggested trying [[:lower:]] instead in post #4:

Quote:
[a-z] is case insensitive
You are encountering problems with locales. POSIX mandates that [a-z] uses the current locale's collation order - in C parlance, that means using strcoll(3) instead of strcmp(3). Some locales have a case-insensitive collation order, others don't.
Another problem is that [a-z] tries to use collation symbols. This only happens if you are on the GNU system, using GNU libc's regular expression matcher instead of compiling the one supplied with GNU sed. In a Danish locale, for example, the regular expression ^[a-z]$ matches the string ‘aa', because this is a single collating symbol that comes after ‘a' and before ‘b'; ‘ll' behaves similarly in Spanish locales, or ‘ij' in Dutch locales.

To work around these problems, which may cause bugs in shell scripts, set the LC_COLLATE and LC_CTYPE environment variables to ‘C'.
sed, a stream editor, 7 Reporting Bugs
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - Iterating a hash through a foreach loop - unexpected results

i've reworked some code from an earlier post, and it isn't working as expected i've simplified it to try and find the problem. i spent hours trying to figure out what is wrong, eventually thinking there was a bug in perl or a problem with my computer. but, i've tried it on 3 machines with the... (5 Replies)
Discussion started by: quantumechanix
5 Replies

2. UNIX for Dummies Questions & Answers

Unexpected Results

Hello, When I run this script, here's what I get: Searching ... found 1111 2222 3333 ..... 7777 ..... 8888 9999 in 95_test Search completed. I expected only to see what number was found in the file, not including the ones not found. Thanks for your help! #!/bin/sh (1 Reply)
Discussion started by: SSims
1 Replies

3. Shell Programming and Scripting

Unexpected Results (at least I did not expect them)

I have two sripts running in bash. The first one uncompresses log files and moves them to a working directory using uncompress -c and > output to new directory. It then creates one control record to assure our search returns a record. It then calls or executes the second script, which is a grep for... (6 Replies)
Discussion started by: altamaha
6 Replies

4. Shell Programming and Scripting

Unexpected results when triggered from cron

Following script gives different results when triggered from Cron compared to when triggered from command line. It is not able to assign values to some variables when triggered from cron. Can any one help? Its a very simple script Script - #! /bin/ksh sFile=$1 sEnv=$2 sWaitFile=$3... (1 Reply)
Discussion started by: sumeet
1 Replies

5. UNIX for Dummies Questions & Answers

Find command gave unexpected results

Hi, I recently executed a find command that caused unexpected permission changes and we had to do a full system restore. Can someone please explain what this command would do? find /staging/admin/scr * -exec chmod 755 '{}' + It caused file permissions inside / to be modified strangely. ... (1 Reply)
Discussion started by: poornima
1 Replies

6. Shell Programming and Scripting

sed Unexpected results, missing first search item

I created 3 files with the identical data as follows dial-peer voice 9999 pots trunkgroup CO list outgoing Local translation-profile outgoing LOCAL-7-DIGITS-NO-PREPEND-97 preference 2 shutdown destination-pattern 9......$ forward-digits 7 dial-peer voice 10000 pots ... (6 Replies)
Discussion started by: popeye
6 Replies

7. Shell Programming and Scripting

Comm giving unexpected results

Hi I am comparing two files with comm -13 < (sort acc11.txt) < (sort acc12.txt) > output.txt purpose: Get non matching records which are in acc12 but not in acc11... TI am getting WRONG output. Is there any constraints with record length with comm? The above files are the two consective ... (2 Replies)
Discussion started by: vedanta
2 Replies

8. Shell Programming and Scripting

Seeing unexpected results when i run through cronjob

Hi I'm having hard time here with below script. If i run script manually i see expected results but, if i keep this script in cron job i'm getting unexpected results. Unexpected results means even though condition is true,cronjob returning output of else condition. This script and cronjob... (2 Replies)
Discussion started by: buzzme
2 Replies
WCSCOLL(3)						   BSD Library Functions Manual 						WCSCOLL(3)

NAME
wcscoll -- compare wide strings according to current collation LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <wchar.h> int wcscoll(const wchar_t *s1, const wchar_t *s2); DESCRIPTION
The wcscoll() function compares the null-terminated strings s1 and s2 according to the current locale collation order. In the ``C'' locale, wcscoll() is equivalent to wcscmp(). RETURN VALUES
The wcscoll() function returns an integer greater than, equal to, or less than 0, if s1 is greater than, equal to, or less than s2. No return value is reserved to indicate errors; callers should set errno to 0 before calling wcscoll(). If it is non-zero upon return from wcscoll(), an error has occurred. ERRORS
The wcscoll() function will fail if: [EILSEQ] An invalid wide character code was specified. [ENOMEM] Cannot allocate enough memory for temporary buffers. SEE ALSO
setlocale(3), strcoll(3), wcscmp(3), wcsxfrm(3) STANDARDS
The wcscoll() function conforms to ISO/IEC 9899:1999 (``ISO C99''). BUGS
The current implementation of wcscoll() only works in single-byte LC_CTYPE locales, and falls back to using wcscmp() in locales with extended character sets. BSD
October 4, 2002 BSD
All times are GMT -4. The time now is 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy