Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error with find

Status
Not open for further replies.

minus0

Programmer
Feb 20, 2003
73
US
Hello,

I am having trouble executing the FIND command. when i do the following command
$ find . -name *log* -atime 2
find: bad option admin.log2003-03-10-00.00.08.203
find: path-list predicate-list

i am getting the above error. can some one tell me what am i missing here?

thanks a bunch
 
try:
$ find . -name "*log*" -atime 2
 
hey

thanks for your tip and it does work the way i want it when i include "*log*" but now i am running into another issue when i try to execute

find . "*log*" -atime 2 -exec ls {} ;

from within a script file i get an error message as
find: incomplete statement

i am including the script itself (just a couple of lines ;) )

#begin
cd $somepath
$(find . "*log*" -atime 2 -exec ls {} ;)
#end
any suggestions?

Thanks again for your help
 
Actually, you need a space before the [tt];[/tt] too. Also, depending on your shell, the [tt]{}[/tt] can be causing you problems. I usually do it like this...
[tt]
find $SOMEPATH -name '*log*' -atime 2 -exec ls \{\} \;
[/tt]
Some finds have a [tt]-ls[/tt] option so you don't have to exec an ls.

Hope this helps.

 
Hi Sam,

What i am trying to do is remove some files that are atleast 2 days old. so the actual command would have a rm in place of ls as in

$(find . "*log*" -atime 2 -exec rm {} ;)

but didn't want to end up removing some files without checking them first which is the reason for the ls.
when i executed the above command (with rm) i didnt get any error messages but the files didnt get deleted either.
any inputs?

Thanks
 
You may also have to use -atime +2 to find files that were accessed more than 2 days ago. 2 on its own will find files accessed exactly two days ago. Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top