Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Most people are familiar with using find to run the same command on a number of files, e.g.:

find -type f | xargs command


find -type f -exec command {} \;

My question is whether it's possible to run multiple commands from find:

find [path] [expression] -exec command1 {} -exec command2 {} \;

so that the output would look like

command1: file1
command2: file1
command1: file2
command2: file2
command1: file3
command2: file3
command1: file4
command2: file4

Obviously I can write a simple shell script wrapper for this, but is it possible to do it all from the command line (perhaps using awk, tee etc.)?

share|improve this question
up vote 1 down vote accepted


find . -exec echo {} \; -exec echo {} \;
share|improve this answer

You could do something simple like this.

find . -exec bash -c 'echo {} ; echo {} ' \;
share|improve this answer
Along with some "{}", this is perfect! – Andrew Oct 8 '10 at 6:16
... ok, I'll have to give it to the other one after all; it does actually give multiple -exec options. But this is also good. – Andrew Oct 11 '10 at 2:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.