Trailing arguments with find -exec {} +

2019-03-05 04:04发布

问题:

I want to add a trailing argument to the appending version of the-exec option of find.

find . -exec echo {} asd +
# expecting the following output:
file1 file2 file3 [...] asd

Does not work as {} must be the last word before +. (Bonus question: Why was that trivial looking feature not implemented?)

What is the simplest expression to archive this, that can handle filenames with spaces and special characters? POSIX conformance would be a nice to have but it is sufficient if it works with Linux.

回答1:

find . -exec sh -c 'echo "$@" asd' _ {} +


标签: linux bash find sh