How to find files with specific extensions, while excluding some names in the current directory only?
3
votes
4
answers
3078
views
I want to **find** some files, in a non GNU environment
- in the current directory only
- with extension **\*.ext1** and **\*.ext2**,
- but not **name1.\*** or **name2.\***
The following command works, but may be not efficient, because the shell expands
./*
and **find** can get a huge list of files and directories.
find ./* -prune \( -name '*ext1' -o -name '*ext2' \) -a ! \( -name 'name1*' -o -name 'name2*' \)
**Update:**
I'm working on AIX, there is no **-maxdepth** option.
Asked by Mattia72
(173 rep)
Dec 7, 2016, 07:45 AM
Last activity: Oct 8, 2021, 10:30 PM
Last activity: Oct 8, 2021, 10:30 PM