How can I create a file in all directories containing a specific file?

I would like to create an empty file "foo" in all directories containing the file "bar" (using find command to find files and then -exec option to create a file in those directories)

+3


source to share


1 answer


You said it (almost):

find -name "bar" -execdir touch foo \;

      



-execdir

is executed from the directory where the file was found. touch

creates an empty file.

+2


source







All Articles