I have a directory containing many sub-directories, each with lots of files having different extensions.
Is it possible for me to filter the output of the tree command so that files having certain extensions like say .log and .msh or certain named directories are not in the output
Consider the example below
.
├── dir1
│ ├── bar.log
│ ├── blahblah
│ │ └── blah.txt
│ ├── hello.txt
│ └── test.msh
├── foo.log
├── out
├── test.py
└── test.txt
2 directories, 8 files
I would like to filter away certain directories (and obviously their contents) and files having certain extensions. For instance I would like to filter away the contents of directory blahblah and all files having extensions .msh and .log
So I would like the output to be
.
├── dir1
│ ├── hello.txt
├── out
├── test.py
└── test.txt
tree command has -I option that allows you to filter out both files and directories that match the given pattern.
tree -I 'blahblah|*.msh|*.log'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With