-1

I have a couple of uninstall files. I want to find all of them and execute them one by one. I know about find and exec combination so I tried

find . -name uninstall -exec {}\;

But this gives me such error :

find: missing argument to `-exec'

Since it is a regular file, I can't give it argument. I just run it like this in terminal

./uninstall

How can I find and execute these files?

1
  • Maybe it's not liking the lack of any dressing on the found-item marker. Try -exec ./{} \;?
    – DopeGhoti
    Commented Oct 9, 2017 at 16:21

3 Answers 3

5

The ; must be a separate argument, that's the argument that tells find where the command to run ends:

find . -name uninstall -type f -exec {} \;

With some find implementations, you can add a -executable predicate before the -exec to only bother trying to execute files that are actually executable.

1

You need to specify a shell to start the file with, e.g.

find . -name uninstall -exec sh {} \;

or

find . -name uninstall -exec bash {} \;
0
0

Via find + shell pipeline:

find . -name uninstall | sh
1
  • It works but it does not wait for user prompt.I mean uninstall files ask me if i am sure to delete.Your function immediately skips to the next file without my input
    – Wardruna
    Commented Oct 9, 2017 at 16:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .