Trailing arguments with find -exec {} +

2019-03-05 03:30发布

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.

标签: linux bash find sh
1条回答
我想做一个坏孩纸
2楼-- · 2019-03-05 03:56
find . -exec sh -c 'echo "$@" asd' _ {} +
查看更多
登录 后发表回答