-----BEGIN PGP SIGNED MESSAGE-----
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.

> 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

- --
Don't work too hard, make some time for fun as well!

Eric Blake             [email protected]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksQPHEACgkQ84KuGfSFAYCB1gCgpnTyWgVAu4FbADRbduFvdkuz
ugUAn3rzSWl2Yiea/BDHf4zAHKS2M5fF
=y0yd
-----END PGP SIGNATURE-----


Reply via email to