[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How test for directory with single quote (') in the name (with find)
From: |
Morgan Weetman |
Subject: |
Re: How test for directory with single quote (') in the name (with find)? |
Date: |
Wed, 4 Mar 2015 17:17:13 -0500 (EST) |
----- Original Message -----
> From: "Peng Yu" <address@hidden>
> To: address@hidden
> Sent: Thursday, 5 March, 2015 2:16:55 AM
> Subject: How test for directory with single quote (') in the name (with find)?
>
> Hi,
>
> The following code shows that if a directory has single quote in the
> name, it does not work. Does anybody know what the correct way is to
> use -exec to test when there is single quote in the command? Thanks.
>
> /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
>
> --
> Regards,
> Peng
>
>
Hi Peng,
Your first example tested that .export was a file so I'm not sure whether you
recreated it
as a directory for the second test or whether you actually wanted a negative
test ( is .export NOT a directory )
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
thanks