Sheio Sheio - 3 years ago 242
Bash Question

Linux find catalogs and print only names

i wanna search for the catalogs which have the "program" in their names and echo these names in console. I have wrote this, but isn't working:

find usr -type d -name "program" -exec echo {}
The error is find: missing argument to `-exec'.

find usr -type d -name "program"

How to fix my command?

Answer Source

Some tiny example with the * wildcard.

find /my/path -name "*program*"

If you don' use wildcards, it will try to find exactly the files named program. Also, echoing is done automatically, you don't need the exec command.

Update Answering to your comment. You can get the base name (name without the path) with:

find . -name "*program*" -exec basename {} \;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download