Peng Yu <pengyu...@gmail.com> writes: > /tmp/tryfind$ find . -type f > ./'/.export > /tmp/tryfind$ find . -type d -exec sh -c "test -d '{}'/.export" ';' -print > sh: -c: line 0: unexpected EOF while looking for matching `'' > sh: -c: line 1: syntax error: unexpected end of file
The problem is that you're constructing the string test -d '/.export and then handing it to sh to execute. But sh applies complex parsing rules, and if there's a ' in the string, it is considered a quoting character. What you want to do is write find . -type d -exec test -d {}/.export ';' -print When find locates the ' directory, it assembles three strings that form the command it is to execute: test -d ./'/.export The nice thing is that find does not put those through sh, but rather executes the exec() call itself, so when test runs it sees two arguments: -d and ./'/.export. test then gives the answer you expect. Dale