Re: bash, grep, and regular expressions
On Fri, 18 Feb 2005 19:38:26 +0000, Pigeon <jah.pigeon@ukonline.co.uk> wrote:
> FWIW I've just tried out every possibility that has been suggested by
> everyone so far. Some of them work as expected, some of them don't.
> There does appear to be a certain amount of weirdness going on, though
> less than Freddy is getting.
The only one that seems to be "weird" is this one:
> ======================
> ls -la | awk '{ if (substr($9,0,1) != ".") {print $9}}'
>
> .
> ..
> .hiddendir1
> .hiddendir2.dir
> .hiddenfile1
> .hiddenfile2.txt
> dir1
> dir2.dir
> file1
> file2.txt
> ======================
For me it seems to behave as intended. The others that "don't work"
have bugs. In particular, "\<" matches the beginning of a word, but
that's defined as an alphanumeric, so it will *never* be the case that
'\<[.]' will match successfully. Many of the expressions are picking
up alphanumeric strings other than the filename, or even just matching
on any two-character sequence where the first isn't a dot and the
second is a lowercase letter.
--
Michael A. Marsh
http://www.umiacs.umd.edu/~mmarsh
Reply to: