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
crontab + exec command naushad Shell Programming and Scripting 4 03-27-2008 12:23 AM
Help with exec command and file descriptors?? rfourn Shell Programming and Scripting 1 07-18-2007 03:05 PM
find command exec error pavan_test UNIX for Dummies Questions & Answers 2 06-13-2006 12:58 AM
exec command g_s_r_c Shell Programming and Scripting 1 09-20-2004 09:20 AM
using the -exec command moxxx68 UNIX for Dummies Questions & Answers 0 04-13-2004 11:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 09-02-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Need help with -exec cp command.

I have a ksh script that contains the following:

find /dir1/dir2 -type f -name "FILE.*" -newer /dir1/dir2/afterme.txt -exec cp /dir1/dir2/dir3 {} \;

When I run it from the cli, it runs fine. When I run it from the ksh script I get
find: missing argument to `-exec'

I also tried -exec cp {} ... and I still got the same error. What's the missing argument?
Reply With Quote
Forum Sponsor
  #2  
Old 09-02-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Assuming you want to copy the files to the directory /dir1/dir2/dir3:

Code:
find /dir1/dir2 -type f -name "FILE.*" -newer /dir1/dir2/afterme.txt -exec cp {} /dir1/dir2/dir3 \;
Regards
Reply With Quote
  #3  
Old 09-02-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
At the bottom of my first post, I mentioned that I already tried it that way. Still got the same error.

Anyone else?
Reply With Quote
  #4  
Old 09-02-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Anyone?
Reply With Quote
  #5  
Old 09-03-2008
Registered User
 

Join Date: Aug 2008
Location: Bangalore , INDIA
Posts: 8
Might the below script will help you ;

find /dir1/dir2 \(-type f -name "FILE.*" -a -newer /dir1/dir2/afterme.txt \) -exec cp {} /dir1/dir2/dir3/ \;

Regards,
Reply With Quote
  #6  
Old 09-03-2008
Registered User
 

Join Date: Jul 2007
Posts: 107
Quote:
Originally Posted by jaiankur View Post
Might the below script will help you ;

find /dir1/dir2 \(-type f -name "FILE.*" -a -newer /dir1/dir2/afterme.txt \) -exec cp {} /dir1/dir2/dir3/ \;

Regards,

Thanks but nah. It returned this error:

find: invalid predicate `(-type'
Reply With Quote
  #7  
Old 09-03-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You need a space after the opening parenthesis. It's not clear why you were getting the error message in the first place but maybe just retyping a different command coincidentally fixes whatever was wrong (missing characters? Random invisible characters?)
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 10:08 PM.


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