find command question

I'm trying to do something like this, is there a way?

find . ! -name ( \*.config -a \*.info )

I want to find all files which don't have the name *.config or *.info.  Can you tell me how to use the "-a" flag to accomplish this?
LVL 3
bryanlloydharrisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ravenplCommented:
find . \! -name \*.config -a \! -name \*.info
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pjedmondCommented:
As always there are many ways to do the same thing. I rather prefer this approach:

find .

lists all the files under . , but we only want files that do not end in *.config or *.info.

The grep for *.info is:

grep "\.info$"

\ escapes the period(.) so that it cannot represent any char, and $ anchors the the match to the end of the line so that names such as abc.info.bu or abc.info2 etc are not matched.

We need to invert this (grep -v) giving:

grep -v "\.info$"

which matches anything *NOT* ending in .info

Finally repeat the process for *.config, and pipe(|) the requirements together:

find . | grep -v "\.info$" | grep -v "\.config$"

et voila!! you have all files not ending in .info or .config

Obviously, this approach is extremely versatile for other search requirements!

HTH:)
0
bryanlloydharrisAuthor Commented:
I see both are great.  I have been using the one from raven for a long time but I am curious if there is a way to save typing from it.

The reason I can't use the grep is because I need to do -exec in the find command.  But I supposed I could then use xargs as well and save some typing.

Thanks both.
0
pjedmondCommented:
I see both are great.  I have been using the one from raven for a long time but I am curious if there is a way to save typing from it.

>>Look up alias!

The reason I can't use the grep is because I need to do -exec in the find command.  But I supposed I could then use xargs as well and save some typing.

>>And....of course you can use grep:) See my approach to this example:

http://www.experts-exchange.com/Operating_Systems/Linux/Q_21816739.html

:)

Thanks both.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.