List files without extension, was: Bug in glob.glob for files w/o extentions in Windows

Francis Avila francisgavila at
Mon Dec 1 01:31:10 CET 2003

Stein Boerge Sylvarnes wrote in message ...
>In article <bqcg7i$olj$03$1 at>, Peter Otten wrote:
>>Georgy Pruss wrote:
>>> Anyway, "*." is not a bad DOS convention to select files w/o extention,
>>> although it comes from the old 8.3 name scheme. BTW, how can you select
>>> files w/o extention in Unix's shells?

In Windows, how do you create a file with a dot as the last character?  In
Unix you can do this, because a dot is just another character in the
filename.  It's because you can't do this in Windows that *. is unambiguous.

>>ls -I*.*
>>The -I option tells the ls command what *not* to show.
>That's non-standard gnu ls behaviour, I think.  (Tested on OpenBSD and

for N in $(ls -1 | grep -v '\.'); echo $N; done

Not positively sure that the -1 option is posix, but it's at least in
OpenBSD and SunOS (in fact, it's the default when output is not to a

Bash also has an extglob option:

$ shopt -s extglob dotglob
$ ls -1 *
$ echo !(*.*)

There's also @(), ?(), *(), +().  You can use multiple patterns within the
parens by joining with '|'.
Francis Avila

More information about the Python-list mailing list