0

I am finding files that do not end with .done like so:

find -type f -not -name \*.done -execdir myscript {} \;

Now, what I want to do is the following:

-pass each found file to myscript

-source each file in myscript with the source command

-run myscript for each sourced file

Note: that I want to run myscript repeatedly, one time for each file that is found. I do not want to run myscript for multiple files simultaneously. So essentially I am seeking to loop over the found files and source them in myscript. How can I accomplish this?

1 Answer 1

1

Your find command runs myscript for every file found, passing the name of the file as the first command line argument to myscript.

You want to source the file in myscript, so myscript should include this in its code:

. ./"$1"

Notes:

  • I assume myscript is interpreted by a shell.
  • You mentioned source but . is more portable.
  • I used ./"$1" because you used -execdir. It seems some implementations of find don't include ./ in the string substituted for {} after -execdir. If this was the case, then this mishap could happen. Adding an explicit ./ prevents this.
0

You must log in to answer this question.

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