The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find command with prune and exec options Sebarry UNIX for Dummies Questions & Answers 2 06-19-2006 04:07 AM
Find command with prune and exec Sebarry UNIX for Advanced & Expert Users 1 06-18-2006 01:43 PM
find command exec error pavan_test UNIX for Dummies Questions & Answers 2 06-13-2006 03:58 AM
ls command doesnt work shawnbishop HP-UX 2 09-01-2005 09:57 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-26-2006
funtochat2002 funtochat2002 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
find command with exec doesnt work

Hi There,
I have a script which finds for log files and removes them if the file has changed in the last day.
The script runs fine without errors. The log file is still there. So, I decided to print the find command and run the command outside the script. Getting "Incomplete statement"
Can you give any ideas?
Thank you.
Unix fan.

Script
*****
#!/bin/ksh
log_home="/export/home/n74915/"
set -x
typeset -i10 days_old=${3:-1}
jobid="$1"
print $jobid
print "Cleaning up"
print $(print $jobid)'t.log'
find $log_home -type f -name $(print $jobid)'t.log' -ctime +$days_old -exec rm {} \; #remove outdated log files
print $?
print find $log_home -type f -name $(print $jobid)'t.log' -ctime +$days_old -exec rm {} \; #remove outdated log files
print $?
print "Cleaned up"
  #2 (permalink)  
Old 07-26-2006
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,739
If I assign values to
log_home
jobid
days_old

this command gives me no errors:
Code:
find $log_home -type f -name "$jobid""t.log" -ctime +"$days_old"
Does jobid have embedded spaces?
  #3 (permalink)  
Old 07-26-2006
funtochat2002 funtochat2002 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
Hi,
Thank you for getting back to me. Jobid doesnt have embedded spaces in it.
I tried the command upto -ctime +1 and didnt get any errors. Its only when I include -exec rm {}\; that I get incomplete statement error. the parameter is not getting passed to rm command ?
Appreciate your help..
  #4 (permalink)  
Old 07-26-2006
tayyabq8's Avatar
tayyabq8 tayyabq8 is offline Forum Advisor  
Moderator
  
 

Join Date: Nov 2004
Location: Bahrain
Posts: 579
Maybe parameter list is too long for exec, try to use xargs and see whats the output.
  #5 (permalink)  
Old 07-26-2006
funtochat2002 funtochat2002 is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
I dont know how to use that command. Could you give me some example?
  #6 (permalink)  
Old 07-26-2006
phrazz phrazz is offline
Registered User
  
 

Join Date: Jul 2006
Location: Alexandria, VA
Posts: 8
lost in space

Code:
-exec rm {}\;
I'm going out on a limb here, but I think you're missing a space
between the last close-curly and the backslash. "Incomplete statement"
is find telling you that it needs something to terminate the -exec clause.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0