[UCLA-LUG] Bash Script / find -ctime help, please
Charles Harvey
soops@threemoonsnetwork.net
Tue, 11 Jul 2000 14:38:03 -0700
Thanks for the explanation, it clarifies alot!
Charles Harvey
Three Moons Network
http://threemoonsnetwork.net
419-818-5260
|>| -----Original Message-----
|>| From: linux-admin@linux.ucla.edu [mailto:linux-admin@linux.ucla.edu]On
|>| Behalf Of Leonard R. Wayne
|>| Sent: Tuesday, July 11, 2000 9:10 AM
|>| To: linux@linux.ucla.edu
|>| Subject: Re: [UCLA-LUG] Bash Script / find -ctime help, please
|>|
|>|
|>| > 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
|>|
|>| _______________________________________________
|>| UCLALUG Linux mailing list - Linux@linux.ucla.edu
|>| http://linux.ucla.edu/mailman/listinfo/linux