[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to conditionally search?

From: Peng Yu
Subject: Re: How to conditionally search?
Date: Fri, 27 Nov 2009 18:09:29 -0600

On Fri, Nov 27, 2009 at 2:54 PM, Eric Blake <address@hidden> wrote:
> Hash: SHA1
> According to Peng Yu on 11/27/2009 8:38 AM:
>>> find . -name '*.sh' -o -name '*.py'
>>> ... do what you had in mind?
>> No. This is not what I want. This will give me all the .sh and .py
>> files. But if there is a .py file and a .sh file with the same suffix
> Same suffix?  How can .sh ever be the same as .py?  Oh, you meant same prefix.

You got what I mean.

>> in the same directory, I only want to show the .py file but not the
>> .sh file.
> Try this.  It finds all *.py files and prints them, and for all .sh files,
> it forks a shell that tests whether a corresponding *.py file exists in
> order to decide whether to print.
> find -name '*.py' -print -o -name '*.sh' \
>  -exec sh -c 'test ! -f "${1%.sh}.py"' sh {} \; -print

I don't quite understand how the command after -exec works. Would you
please let me know how "-exec sh -c 'test ! -f "${1%.sh}.py"' sh {} \;
-print" works?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]