LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-25-2009, 06:20 PM   #1
andrew_26
LQ Newbie
 
Registered: Aug 2009
Posts: 1

Rep: Reputation: 0
Use of find & exec


Quote:
Originally Posted by Tinkster View Post
find may well be the right tool for the job,
[/INDENT]depending on the criteria you want to apply
for the selection of files ...

find <start directory> -iname "<all my files type>" -exec cp {} <target_dir> \;
The first part works great but i cant get it to take an argument for -exec
im doing something wrong but i dont know what.


[/home/andrew/photos]
[18:51:17 root]$ find . -type f -exec cp {} /home/andrew/images/
find: missing argument to `-exec'
[/home/andrew/photos]
[18:52:16 root]$ find . -type f -exec cp {} /home/andrew/images/\
>
[/home/andrew/photos]
[18:52:25 root]$ find . -type f -exec cp {} /home/andrew/images/;
find: missing argument to `-exec'
[/home/andrew/photos]
[18:52:33 root]$ find . -type f -exec cp '{}' /home/andrew/images/;
find: missing argument to `-exec'
[/home/andrew/photos]
[18:52:50 root]$ find . -type f -exec cp "{}" /home/andrew/images/;
find: missing argument to `-exec'
[/home/andrew/photos]
[18:53:05 root]$ find . -type f -exec cp "{}" /home/andrew/images/\;
find: missing argument to `-exec'
[/home/andrew/photos]
[18:53:13 root]$ find . -type f -exec cp "{}" /home/andrew/images/\;
find: missing argument to `-exec'

Last edited by Tinkster; 08-26-2009 at 06:43 PM. Reason: fixed quoting
 
Old 08-26-2009, 01:46 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Try
Code:
find . -type f -exec cp {} /home/andrew/images/ \;
I think you tried every combination except that one!
 
Old 08-26-2009, 06:15 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
Resurrecting long dead threads (see dates) is usually frowned upon. Starting a new one is recommended.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find with -exec argument - not giving proper output..how to find... hinetvenkat Linux - Server 4 01-25-2010 06:19 AM
find -exec syntax: bug in find? mfcarroll Programming 5 06-21-2007 07:13 PM
find -exec help dc144 Linux - Newbie 3 10-12-2006 02:14 AM
Help sought with 'find -exec' drjones69 Linux - Software 2 04-27-2005 04:02 AM
find -exec cricbk Linux - Newbie 4 01-05-2004 07:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration