Arno Lehmann wrote: > By the way, the shell expansion does not use regular expressions... > > To select only stuff starting with a dot, in a regular expression you > should write '\.[^\.].+'. Unless I'm wrong, of course :-) > > That RE would be spelled like "take everything which starts with a dot, > and is followed by one character which is not a dot, and is followed by > at least one character".
That's not a bad port of the intent of the "standard Unix shell glob trick". Of course, were someone to name a file simply ".a", both it and the Unix globbing trick would fail. And, unfprtunately, it is not compliant with the rules of POSIX extended regexes. To catch ALL dotfiles in Bacula, where . and .. are not concerns, one could simply use the following regex: '^\..*' which would denote any filename beginning with a literal . followed by zero or more additional characters. In a more general environment where . and .. are concerns and we don't want recursive selection of current and parent directories, the problem is more complex. We want to accept filenames beginning with a dot and having at least one additional character, with the restriction that the second character may not also be a dot. That would look something like this: '^\.([^.]|\..).*$' Note that there is NOT a \ escaping the . in the bracket expression. This is because matching rules are different within POSIX bracket expressions. Quoting from regex.3: To include a literal `]' in the list, make it the first character (following a possible `^'). To include a lit- eral `-', make it the first or last character, or the sec- ond endpoint of a range. To use a literal `-' as the first endpoint of a range, enclose it in `[.' and `.]' to make it a collating element (see below). With the excep- tion of these and some combinations using `[' (see next paragraphs), all other special characters, including `\', lose their special significance within a bracket expres- sion. The important part of that, for our purpose, is the last sentence, because it means that within a [] pair, a \ is just a \, a . is just a ., a psi is just a psi[1]. So not only is it impossible to escape the dot within a bracket expression but, fortunately, we don't need to. So, the above expression can be read as thus: ^\. Match anything which begins with a literal . ( followed by EITHER [^.] a character which is not a literal . |\.. OR a second literal . followed by ANY character ) (end of the EITHER-OR part) .* followed by ANY ZERO OR MORE additional characters $ and then ends. [1] It'll all become clear, as time goes by. -- Phil Stracchino [EMAIL PROTECTED] Renaissance Man, Unix generalist, Perl hacker Mobile: 603-216-7037 Landline: 603-886-3518 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642 _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users