hi folks,
I am trying to write a script for deleting all the files which are older than "N" days from current directory.
CODE:
FileName="*.*"
NumDays=-1
echo $FileName
echo $NumDays
find * -prune -name $FileName -mtime $NumDays -exec rm {} \;
Now the problem here is when i am trying to print the 'FileName' variable here its printing all the files here and not "\*.*" so the 'find ' statement is not working .\(its not deleting the files\)
I have tried with "\\*" char also but its not working .
How to do that ??
Have a look at this . Pls perform search before posting your question.
hi shereen,
thanx for prompt reply,
i read the link sent by u but its not giving me the solution.
my script is NOT giving me any error like "find: Argument list too long."
my problem is the variable is replaced by its values (*.*)
If you look closely, you will see that though you are not running into the "Argument list too long" error, the problem remains the same. The *.* is being expanded into the list of filenames.
Enclose your $FileName variable inside double quotes to resolve the problem. In fact, that is the solution given in that particular post as well.