I have been living with this problem with GNU sed v4.1.4 for a long time, but now I really need to figure it out.
When using a list in either an address or a search, the expression [a-z] is matching lower and upper-case letters. [A-Z] works as it should.
For example, if I run
Where temp.txt contains only
it matches every line.
If I run it using [A-Z] it matches only the upper-case letters as I would expect. Also, when I run
It matches only the lower-case letters again as I expect. It seems only [a-z] is affected, and only with sed.
Does anyone know why this is? Maybe there is something wrong with the way I have the system set up, but everything else seems to be working ok.
1) The first sed expression you gave does not match upper-case characters when I test it.
2) grep does not use / / as regular expression beginning and end markers; your grep expression couldn't possibly have worked.
So, unless your version of sed is extremely strange, I think you've simplified the problem a little too far, reducing it into something which doesn't actually demonstrate your problem. Could you post the actual expression you're having problems with please?
1) 2) grep does not use / / as regular expression beginning and end markers; your grep expression couldn't possibly have worked.
So, unless your version of sed is extremely strange, I think you've simplified the problem a little too far, reducing it into something which doesn't actually demonstrate your problem. Could you post the actual expression you're having problems with please?
Corona, sorry I got careless cutting and pasting, the grep command was
I just tried it again and the result was correct.
The sed example in the post is an example of an expression that exhibits the problem on my system (apparently not others'). I verified that also.
Here is something that is easier to cut and paste to the command line.
The result is xxxx on my machine. Not the expected xxAB.
Perhaps I do have a strange version of sed. One thought is whether it could be that the regex library not correct for the sed version. I don't know if that is the case or how to check.
Scrutinizer, Yes it works with classes, but that doesn't solve the problem.
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'.
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)
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)
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)
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)
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)
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)
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)
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)