The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Crontab not recognizing the jar files rajuutla UNIX for Dummies Questions & Answers 4 05-01-2008 11:20 PM
Crontab not recognizing the jar files rajuutla Linux 3 05-01-2008 05:27 AM
Crontab not recognizing the jar files rajuutla UNIX for Advanced & Expert Users 0 04-30-2008 03:39 AM
recognizing * character csejl Shell Programming and Scripting 3 11-15-2005 10:55 PM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 02:38 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2006
Registered User
 

Join Date: Jul 2006
Posts: 7
Stumble this Post!
recognizing *.* in find

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 ??
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-16-2006
tayyabq8's Avatar
UNIX Hobbyist
 

Join Date: Nov 2004
Location: /World/Asia/MiddleEast/Kuwait/Salmiya
Posts: 518
Stumble this Post!
Have a look at this . Pls perform search before posting your question.
Reply With Quote
  #3 (permalink)  
Old 07-16-2006
Registered User
 

Join Date: Jul 2006
Posts: 7
Stumble this Post!
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 (*.*)

Reply With Quote
  #4 (permalink)  
Old 07-17-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,323
Stumble this Post!
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.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:44 AM.


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

Content Relevant URLs by vBSEO 3.2.0