Absurd behavior of Regex
Hi all..
I have two files in the directory test named text[*?!1] and text[2*?!] ls text*[!2-4]* output is : text[*?!1] text[2*?!] ls text*[!2-4] output is : text[*?!1] text[2*?!] In both the examples text[2*?!] should not appear, since i am trying to avoid numbers from 2 to 4. why regex behaves like this ? Any help will be greatly appreciated.... |
What are the real, actual names, of these file in question, and what is it you expect to happen?? That would be handy in trying to diagnose what is the problem with the regex you are using.
Sasha |
Quote:
I am preparing for a certification..whatever names I have specified are the real name of files . In the output of both the ls commands I don't expect text[2*?!] in the output |
you do have weird filenames :-)
|
Quote:
|
your "*" matches too many characters, try
ls text?[!2-4]* |
to be precise: your "*" matches éverything to the end of the fileneme, that's why ls text*[!2-4]* and ls text*[!2-4] are equivalent.
|
Quote:
|
Quote:
Sasha |
Quote:
I have tried following... [vinay@localhost temp]$ ls text[*?!1] text[2*?!] [vinay@localhost temp]$ ls text*[!2-4]* text[*?!1] text[2*?!] [vinay@localhost temp]$ ls text*[!2-4] text[*?!1] text[2*?!] [vinay@localhost temp]$ ls text?[!2-4]* text[*?!1] Last command solved my doubt.... |
Hi GrapefruiTgirl,
i couldn't beleive it at first, but these ARE his filenames, that's why i called them weird. Code:
> "text[*?!1]" |
All times are GMT -5. The time now is 05:41 AM. |