On 03/04/2015 11:17 PM, Morgan Weetman wrote:
> The example below has assumed that you wanted to test that .export was a file:
> 
> find . -type d -exec sh -c "test -f \"{}\"/.export" \; -print
> 
> .. works for me on 4.5.11

Well, the problem is when now a directory has a double quote '"' in its name:

$ mkdir 'hello"world'
$ touch 'hello"world/.export"
$ find . -type d  -exec sh -c "test -f \"{}\"/.export" \; -print
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file

The best I could think of is to avoid the extra shell, and to directly
invoke /usr/bin/test instead:

  $ find . -type d  -exec test -f '{}'/.export \; -print

This will work for both, directory names with '"' and with '\'' in their names.

Have a nice day,
Berny

Reply via email to