Reputation: 19664
man tree
says
-I pattern
Do not list those files that match the wild-card pattern.
However, when I specify:
$ tree . -I .*~ -I *egg-info
I still see:
tree . -I .*~ -I *egg-info -I *.pyc
.
├── bin
├── LICENSE
├── Makefile
├── Makefile~
etc., it's still showing Makefile~
even though there's a terminal ~
What's the right syntax to get tree to ignore the pattern I have given it?
Upvotes: 1
Views: 876
Reputation: 1508
As per the man page extract you quoted, tree
uses "wild-card pattern" which is a common synonym for "glob" or "glob pattern". In this paradigm *
is the syntax for "a any number of any character".
(.*
is the equivalent form in the regex paradigm.)
Your first ignore pattern -I .*~
is then searching for a .
character followed by a *
then a ~
.
In this you simply mixed up the regex form with the glob form.
And as you can see, your other patterns worked the way you wanted because they don't have a prepended .
in them.
Upvotes: 0
Reputation: 354
I see a few possibilities in your command. (Not knowing the 'flavor' of your unix, it's hard to pinpoint exactly).
.*
Unix has "hidden" files. These are files whose name starts with a DOT. In Reg Ex, DOT ASTERISK means 0 or more characters. With file names, DOT ASTERISK means all hidden files and no visible files. Makefile~
is a visible file, not a hidden file, so it will not be excluded. You may need to replace DOT ASTERISK TILDE with ASTERISK TILDE.-I
= Exclude files, not exclude directories. If Makefile~
is a directory name, the -I
may not exclude it.-I M*
will read the current directory and expand M*
into every filename in the current directory. So, -I M*
couild be "globbed" (or replaced) with -I Milk Money Margaret_is_a_Beauty
. Use quotation marks around your wildcards. Try -I ".*~"
or -I '.*~'
Upvotes: 2