Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Ê×Ò³>>Unix&Linux>>A Question Regarding the 'Find' Command

A Question Regarding the 'Find' Command

chartpacs
02-15-2006, 11:26 AM
Hello,

If I want a list of files in the current directory that have the jpg extension, I might do something like:

find . -iname "*.jpg"

Is there any way I could determine that, if there are files in the directory, they *only* are jpgs, rather than a mix of jpg, gif, png, etc.? Maybe this doesn't involve the 'find' command.

Regards,
Sean Mills

dmacks
02-15-2006, 01:06 PM
You could invert the find so that you get a list of files that do not have the jpg extension.

slacker
02-15-2006, 03:28 PM
Try this:

find . -type f -name "*" -print | grep --ignore-case --invert-match .jpg

Anything that appears is a file without .jpg in the filename (I think you add $ to extension for end of file name, but I forget if that is only in egrep (.jpg$).

guardian34
02-15-2006, 03:37 PM
Do you mean that you want to see if a folder contains only jpg files, and not anything else? Then you could try something like this:

find . -not -iname '*.jpg'

That may show a period for the current file, as well as invisble files. If you don't want to show those, you could try something like this:

find . -not -iname '*.jpg' -not -iname '.*'


 

TOP

Windows Server Outsell
Unix Signals And C++ E

For more info

Unix Signals And C++ E
Windows Server Outsell
bash not using my .bas
Applescript: Hide Proc
help with installing p
Mozilla install from d
ssh - don't want to us
Escaping quotes in Tig
Terminal Keybindings 
JAVA help, please! 

News Archive

Displaying Images on t
Install Office from th
Terminal Problem...? 
cc1plus not executable
desktop icons.. 
at & growlnotify 
unknown terminal type 
scp arbitrary files 
What and why is a 'Dis
permissions already me

Related stories:

Applescript for Terminal Commands
Catching a snoop ?
How to find out what's playing the submarine.aiff sound?
which online man pages for 10.4 ?
rm command that includes dot-files?
file attributes
Script to copy AND encode Audio CD
Represent ?symbol in command line?
Regular expressions: find paragraphs not containing??

Copyright@2004-2005 www.zzcoke.com All Right Reserved

link:Citenna