1

tree shows

...
│  ├── template_one_file.sh
│  ├── template_sed.sh
│  ├── testy.sh
│  ├── tmp
│  │  ├── file1.html.13567_old
│  │  ├── file2.html.13567_old
│  │  ├── file3.html.13567_old
│  │  └── file4.html.13567_old
│  └── use_case_to_add_etc_2_numbers
└── vi
 ├── vim_tips_and_chearsheet
 └── vi_stuff
160 directories, 713 files

and I can ignore the tmp directory (for example) with tree -I 'tmp' -L 4

...
│  ├── template_multiple_files.sh
│  ├── template_one_file.sh
│  ├── template_sed.sh
│  ├── testy.sh
│  └── use_case_to_add_etc_2_numbers
└── vi
 ├── vim_tips_and_chearsheet
 └── vi_stuff
157 directories, 709 files

but why can I not ignore individual files such as the _old files with

tree -I 'old' -L 4

which still shows the _old files

...
│  ├── template_multiple_files.sh
│  ├── template_one_file.sh
│  ├── template_sed.sh
│  ├── testy.sh
│  ├── tmp
│  │  ├── file1.html.13567_old
│  │  ├── file2.html.13567_old
│  │  ├── file3.html.13567_old
│  │  └── file4.html.13567_old
│  └── use_case_to_add_etc_2_numbers
└── vi
 ├── vim_tips_and_chearsheet
 └── vi_stuff
160 directories, 713 files

I tried '.*old' and '.*old$' patterns but that didn't help.

asked Jun 2, 2017 at 20:00
1
  • 1
    Use shell glob patterns, not regex. Commented Jun 2, 2017 at 20:05

1 Answer 1

5

Use a wildcard:

tree -I '*_old' -L 4

Reference: man tree (my emphasis)

-I pattern

Do not list those files that match the wild-card pattern.

answered Jun 2, 2017 at 20:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.