wildcard vs regular expression
Hi,
I've come across the term wildcard and regular expression. Both looks very similar, thus very confusing. may I know what's the difference between these two? Thank You very much |
They have a slight similarity, however,
regexp are way more powerful. A wildcard is ie an * and replaces any sequence of characters. Regexps allow for differnt setups, like explicitly searching for numeric components and such. Cheers, Tink |
Hi,
I have a question which I'm not sure if my ans is right. For example if a directory contains the following files, what's the command to list the files ending with a number less than 3 and the command to list the files ending with any single digit number. The files as follows abc1 abc2 abc3 abc11 My ans for the question is ls *[0-2], but it list the file abc11 as well. Is there any more specific command to both the questions shown above? Thanks you very much |
Hi,
Does anyone have any idea how it can be done? Apprecite if someone can help me out with this question, thanks alot |
well just for that particular example you could do:
ls ???[0-2] |
Quote:
Code:
ls *[0-2]{1} |
Actually, the asterisk '*' symbol is just one of many used by various regex engines. It generally denotes zero or more chars at that position in the regex.
If you want to know more, try man 7 regex or http://regex.info , the wbsite devoted to Mastering Regular Expressions by Jeffrey Friedl, generally acknowledged to be the definitive book. There's a full searchable index link on the front page. |
All times are GMT -5. The time now is 02:22 PM. |