Jochen Weiland
Jochen Weiland

Reputation: 33

How to create a file in all directories that contain a specific file?

I would like to generate an empty file "foo" in all directories that contain a file "bar" (by using the find command to find the files and then the -exec option to create the file in these directories)

Upvotes: 3

Views: 32

Answers (1)

Tom Fenech
Tom Fenech

Reputation: 74685

You said it (almost):

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

-execdir executes from the directory in which the file was found. touch creates an empty file.

Upvotes: 2

Related Questions