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?
Corona, sorry I got careless cutting and pasting, the grep command was
grep "[a-z]" temp2.txt
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.
echo abAB | sed -r "s/[a-z]/x/g"
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.
If it really is a bug in sed, the obvious thing to do would be to upgrade your version of sed...
If your system has busybox on it, it may be a viable alternative.
$ busybox sed
Usage: sed [-efinr] SED_CMD [FILE]...
Options:
-e CMD Add CMD to sed commands to be executed
-f FILE Add FILE contents to sed commands to be executed
-i Edit files in-place
-n Suppress automatic printing of pattern space
-r Use extended regex syntax
If no -e or -f is given, the first non-option argument is taken as the sed
command to interpret. All remaining arguments are names of input files; if no
input files are specified, then the standard input is read. Source files
will not be modified unless -i option is given.
$