On 18:19 13 Feb 2003, Vikram Goyal <[EMAIL PROTECTED]> wrote:
| The files in one of my dir are:
| . .. .aliases .aliases.sav attach
| dean inbox interesting lists .log.02-01-11
| .log.02-01-12 .log.02-01-13 .log.03-02-01 .log.03-02-02 .log.03-02-03
| .log.03-02-04 .log.03-02-05 .log.03-02-06 .log.2-01-11 .log.2-1-11
| .log.2-1-12 .msgid.cache sent .tmp trash
|
| I want bash to match the following pattern in file listing but it
| dosen't do that. Can you point what I am doing wrong.
|
| ls Mail/.log\.[0-9]*$(($(date +'%y')-1))-[01]*$(($(date +'%m')-1))-*
|
| Output is:
| Mail/.log.02-01-11 Mail/.log.02-01-12 Mail/.log.02-01-13
|
| The asterix is not being considered.
It's "asterisk". Asterix is a Gaulish character in a cartoon.
| Why the files .log.2-01-11 .log.2-1-11 .log.2-1-12 are not matched?
| Any solution...
"date +%y" and "date +%m" return 2 digit results. I see you're subbing
1 from each.
So your pattern is really:
Mail/.log\.[0-9]*1-[01]*1-*
I think your are trying to use regular expression syntax. The shell
doesn't use that; instead it uses globs. A lot less flexible, but usually
better for matching filenames.
So, in globs:
dot (.) is not special. So "." and "\." are just dot.
"*" in a shell glob means what ".*" means in a regular expression:
zero or more characters.
I believe you're being screwed up by your leading [0-9]s. For example, this:
[0-9]*1
_must_ match at least 2 characters: a digit for the "[0-9]"; some stuff,
possibly empty, for the "*", and then a "1". It will _not_ match the
"2" in "Mail/.log.2-01-11".
Does this illuminate the problem?
--
Cameron Simpson, DoD#743 [EMAIL PROTECTED] http://www.zip.com.au/~cs/
GET ON YOUR BIKES AND RIDE!! - Queen
--
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/redhat-list