Regular Expression Case Sensitivity

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Thomas Mondoshawan Tate
Date:  
Subject: Regular Expression Case Sensitivity
--uAKRQypu60I7Lcqm
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Tue, Dec 04, 2001 at 11:54:44AM -0800, Simper, Brian D wrote:
>=20
> Try this in an empty directory and let me know if this is a bug or a feat=

ure
> or an error on my part.
>=20
> Create several files of upper and lower case names:
>=20
>     touch aaaa
>     touch AAAA
>     touch bbbb
>     touch BBBB
>     touch 1234
>     touch .abcd
>=20
> Now use a regular expression to delete all files starting with a lower ca=

se
> letter:
>=20
>     rm [a-z]*


What you're asking it to do in regexp speak is remove all files that start
with ZERO or more lowercase a-z characters, this would provide the desired
result, if the shell used regexp. Bash, however, does not -- the [a-z] will
match the first beginning character, and the * will fill in the rest.
Running Bash 2.05.0(1)-release, this command will delete only the aaaa and
bbbb files. Note that the .abcd file is untouched. The reason for this is
because it starts with a single "." character, not a lowercase letter.
(Additionally, any file that begins with a single "." character is
considered to be a "hidden" file in the *NIX world -- to see them in an ls
command, append -a to the command line)

> 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.


Which version of Bash are you running? (echo $BASH_VERSION)
It might be a bug related to the older v1.xx versions of the shell -- IIRC,
RedHat still installs v1.xx as the default shell, though I may be mistaken
since I've not touched RH since v6.2.

--=20
Thomas "Mondoshawan" Tate

http://tank.dyndns.org

--uAKRQypu60I7Lcqm
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8DTxNYp5mUsPGjjwRAlITAKCIpXeLGaV2nIqRMkobgzM4O3JcTQCgttR7
fmNiutzOZtF1XgevQVG1A8E=
=NNdG
-----END PGP SIGNATURE-----

--uAKRQypu60I7Lcqm--