[UCLA-LUG] Bash Script / find -ctime help, please

Leonard R. Wayne lwayne@jpl.nasa.gov
Tue, 11 Jul 2000 09:09:49 -0700


> find -maxdepth 1 -type f \( -ctime +60 -o \! \( -name \*.jpg -o \) \) -exec rm -f \{\} \;

You might be looking at the wrong man page.
To understand the '-o' parameter, look at
the man page for 'find.'  (On my computer,
which is running Red Hat 6.1, the man page
describes '-o' very close to the end of the
man page, in the section titled 'OPERATORS').

I suspect the '!' character means 'not'.
In other words, '! true' would mean 'not 
true.'

The \'s mean "don't interpret the next
character as a special shell character."  
For example, '*' is a special character,
interpreted by the shell.  It causes all
matching filenames to be inserted into the
command line before the command is actually
passed to 'find.'  But the way 'find' works,
you don't want to do that.  You just want
to pass the character '*' to the 'find'
command.  So you put a '\' in front of it
to make sure the shell does not interpret
the character for you.  This applies 
similarly to the characters: ( ) { } ! ;

I didn't explain that very well.  My favorite
book for this kind of stuff is Harley Hahn's
'A Student's Guide to UNIX.'  However, I 
think that book deals more with C-shell than
Bash, which you said you are working with.
(There is a lot of overlap, of course.)
Maybe somebody can recommend a good book on
Bash?

- Len