3

I have some executable files under a directory tree. I want to find them and execute them the most simple way. I've tried this so far: find . -perm 0775 -type f | xargs exec But exec is not an executable, it is a bash internal. I could create a wrapper script which could look like this:

#!/bin/bash
# exec.sh
exec $1

And then could run find . -perm 0775 -type f -exec ./exec.sh {} \; But there's gotta be a more elegant and shorter way of doing that.

2 Answers2

6

Just drop the script.

find . -perm 0775 -type f -exec '{}' ';'

works just fine!

Jan Hudec
  • 1,025
0

xargs is not really suited to doing this; it is mainly meant to supply a fixed command with arguments read from standard input.

But you can call the programs directly using a simple shell loop:

find . -perm 0775 -type f | while read program; do
                                $program
                            done
JyrgenN
  • 141