Regular Expression Case Sensitivity

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matt Alexander
Date:  
Subject: Regular Expression Case Sensitivity
rm [a-z]* isn't a regular expression because it's being interpreted by the
shell, which would use the * as a wild card. In a regular expression, the
* would match ZERO or MORE of the proceding characters, so your expression
would have removed all files.
I ran this command on a RH 7.1 box and it only deleted the lowercase
files. Also, you can save yourself a bit of typing by using this instead:

touch aaaa AAAA bbbb BBBB 1234 .abcd




On Tue, 4 Dec 2001, Simper, Brian D wrote:

>
> Try this in an empty directory and let me know if this is a bug or a feature
> or an error on my part.
>
> Create several files of upper and lower case names:
>
>     touch aaaa
>     touch AAAA
>     touch bbbb
>     touch BBBB
>     touch 1234
>     touch .abcd

>
> Now use a regular expression to delete all files starting with a lower case
> letter:
>
>     rm [a-z]*

>
> When I was experimenting with this all of the files starting with *any*
> alphabetic character were deleted. This was unexpected and I'm not sure if
> I am misinterpreting the regular expression or if I am delusional. Let me
> know what you get. FYI, I am using Red Hat Linux 7.2 so I would be
> interested if it's just me.
>
> Brian
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
>
> PLUG-discuss mailing list -
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>