> I am working on Linus/SuSE61 and I have the following problem:
> on the "sh" (/bin/sh) the command "rm [A-Z]*" remove the all files, including
> the ones that begin with the capitals letter. Why? 

It removed the files because you instructed it to do so!

The pattern "[A-Z]*" matches all file names that begin with capital
letters.  The shell will expand that into an argument string which is
then passed to the "rm" command.  The "rm" command will then remove
those files.  Is that not what you wanted when you said "rm [A-Z]*"?

It is much safer to understand and debug these commands by using the
shell "echo" command.

  echo rm [A-Z]*

That will print to your terminal the result of the filename expansion.
You will see the arguments that the "rm" command is getting.  The
"echo" is safe because it only prints and does not remove.

Your message implies that you wanted all files except those with
capital letters.  In that case you need to invert the character class
with the '^' metacharacter.

To match files starting with a non-capital letter:

  echo rm [^A-Z]*

Or to match files starting with a lower case letter:

  echo rm [a-z]*

Note that upper [A-Z] and lower [a-z] are only a small portion of the
legal character set for file names.  Any character is valid except for
'/' and the null character.

Hope this helps.

Bob Proulx

Reply via email to