0

I have this file structure

user@laptop:/my/folder$ ls
control       changelog  patches   postrm  source
copyright.in  mime       postinst  rules

and want to list all files without dot in name. Don't want use grep. Reverse look like:

user@laptop:/my/folder$ ls *[.]*
copyright.in

But when I try to add negation (^ or !) to achive my goal, it doesn't work:

user@laptop:/my/folder$ ls *[^.]*
control  copyright.in  changelog  mime  postinst  postrm  rules

patches:
series                                      03-include-unistd-for-kfreebsd
01-manpages-in-section-1-not-in-section-1l  04-unzip60-alt-iconv-utf8
02-branding-patch-this-is-debian-unzip      04-unzip60-alt-iconv-utf8~

source:
format

In output there is copyright.in listed, which is not what I want. When I write ?? instead of *, it works.:

user@laptop:/my/folder$ ls *[^.]??
control  changelog  mime  postinst  postrm  rules

patches:
series                                      03-include-unistd-for-kfreebsd
01-manpages-in-section-1-not-in-section-1l  04-unzip60-alt-iconv-utf8
02-branding-patch-this-is-debian-unzip      04-unzip60-alt-iconv-utf8~

source:
format

Anybody knows how to make list of files in directory without dot in name using globbing?

Ľubomír Mlích
  • 649
  • 6
  • 12

1 Answers1

2

(Sorry for the last answer, I totally misread the question.)

You can use grep:

[me@localhost ~]$ ls | grep -v '\.'

Or find:

[me@localhost ~]$ find . -maxdepth 1 -not -name '*\.*' -printf '%f\n'

Or even ls:

[me@localhost ~]$ ls -1I '*.*'

All produce the same output. (The -1 in ls isn't necessary, it's just to force one filename per line so that its output is the same as the other two commands.)

TypeIA
  • 16,916
  • 1
  • 38
  • 52
  • Yes, I know I can use grep, but I don't want to (fifth line of question). Thanks. – Ľubomír Mlích Mar 04 '14 at 16:23
  • 2
    @ĽubomírMlích which is why I posted an alternate solution using `find` (and another using `ls`). However, you fail to say *why* you don't want to use grep, and I can't really think of any good reasons. – TypeIA Mar 04 '14 at 16:24
  • ok, ok ;-) I'd like to configure logadm to use rotate all files (maybe its not good idea and I should list these files manualy) in directory without dot. Logadm config file looks like this: /my/folder/* -C 5 -c -p 1d -t '$file.%Y%m%d' More about [logadm](http://www.c0t0d0s0.org/archives/6394-Less-known-Solaris-features-logadm.html) – Ľubomír Mlích Mar 04 '14 at 16:31