The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Perl Script Error with find command MKNENI Shell Programming and Scripting 4 03-26-2008 09:02 AM
find command with exec doesnt work funtochat2002 Shell Programming and Scripting 6 07-26-2006 11:29 AM
Find command with prune and exec options Sebarry UNIX for Dummies Questions & Answers 2 06-19-2006 01:07 AM
Find command with prune and exec Sebarry UNIX for Advanced & Expert Users 1 06-18-2006 10:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-12-2006
Registered User
 

Join Date: Oct 2005
Posts: 44
find command exec error

Hi All,

i am writing a shell script in korn shell
which deletes all the files in a directory
once in every 10DAYS.

the directory has different format files.

the script has something like this;


cd /home/data/pavi
echo "Please Enter the Number of Days to search for"
read DAYS
echo "The entered number of days is $DAYS"
DOACTION="rm -rf"
find DD.* -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;
find AA.* -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;

the script is working fine DD.* extension.

But for those files with AA.* extension i am getting the following
error message;

pav.ksh[33]: find: Argument list too long.
there are total 22,309 files with AA.* extension.

can anyone please suggest me the best approach here,

thanks
pavi
Reply With Quote
Forum Sponsor
  #2  
Old 06-12-2006
tayyabq8's Avatar
Moderator
 

Join Date: Nov 2004
Location: Bahrain
Posts: 555
Check the max length of arguments to exec:
Code:
grep 'ARG_MAX' /usr/include/limits.h
or Try this:
Code:
find AA.* -maxdepth 1 -mtime +$DAYS | xargs $DOACTION
Regards,
Tayyab

Last edited by tayyabq8; 06-12-2006 at 09:43 PM.
Reply With Quote
  #3  
Old 06-13-2006
grial's Avatar
El UNIX es como un toro
 

Join Date: Jun 2006
Location: Madrid (Spain)
Posts: 531
Quote:
Originally Posted by pavan_test

find DD.* -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;
find AA.* -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;
You should change these two lines into:

find . -name "DD.*" -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;
find . -name "AA.*" -maxdepth 1 -mtime +$DAYS -exec $DOACTION {} \;

Quote:
Originally Posted by pavan_test
pav.ksh[33]: find: Argument list too long.
there are total 22,309 files with AA.* extension.
This error is produced by the use of "*". It means there are too many files on the directory. That's because of the shell's limits when using wildcards.

Regards.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0