Find 2nd level directories without files with a certain extension

I have a lot of directories and subdirectories like:

abc/123/

abc/456/

def/789/

Some of them have jpeg files on them:

abc/123/

abc/456/foo.jpg

abc/456/bar.jpg

def/789/foo.jpg

I want to find the one that are missing a jpg

Learning from here I was able to get what I wanted with:

find . -mindepth 2 -maxdepth 2 -type d ‘!’ -exec sh -c ‘ls -l “{}”|egrep -i -q “*\.jpg$”‘ ‘;’ -print

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s