LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-31-2010, 01:06 PM   #1
ele003
LQ Newbie
 
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
I don't get find command


When I run find command with exec option, it just hangs on me. what am I doing wrong?


find /stdlist -type d -mtime 0 -exec cp -r {} joblogs \;
 
Old 03-31-2010, 01:14 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Welcome to LQ.

first, does it work as expected without the -exec option?

Looking at the man page under the -exec option, I don't find syntax that relates to what you are showing. What is the generic syntax?
 
Old 03-31-2010, 01:18 PM   #3
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Hmm.. Command looks ok to me -- pixellany, what looks out of place to you?

..And the command works fine (appears to work fine) when I test it using `echo` instead of `cp`

I have a theory though: any chance "stdlist" and "joblogs" are in the same directory structure containing a lot of directories, and a recursive mess is happening? i.e. as the copying progresses, more directories are being created and copied, and on and on...?
 
Old 03-31-2010, 01:35 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by GrapefruiTgirl View Post
Hmm.. Command looks ok to me -- pixellany, what looks out of place to you?
I don't know!!! i just could not immediately match it up to the syntax examples in the man page.
 
Old 03-31-2010, 01:41 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
Maybe its just taking a long time if you have alot of files.
 
Old 03-31-2010, 02:22 PM   #6
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Try using something like this.

Code:
find /stdlist -type d -mtime 0 -exec cp -rv -t joblogs '{}' \+
The + at the end makes -exec work more like xargs; all the files are run in a single process. Also, using the -t option in cp is safer (as is -v), and the brackets should generally be quoted.
 
Old 04-01-2010, 08:06 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I note also that David puts the brackets after all other arguments to cp. This seems to better match the syntax examples in the man page.
 
Old 04-01-2010, 06:37 PM   #8
alinas
Member
 
Registered: Apr 2002
Location: UK, Sywell, EGBK
Distribution: RHEL, SuSE, CentOS, Debian, Ubuntu
Posts: 60

Rep: Reputation: 20
ele003, there is nothing wrong with your command. I bet it's just taking a long time. Your are copying recursively, it may be a lot more information than you thought!
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find/grep command to find matching files, print filename, then print matching content stefanlasiewski Programming 9 06-30-2016 05:30 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM
Single find command to find multiple files? thok Linux - Newbie 7 01-31-2009 04:45 PM
Using a single "Find" Command to find files bases on multiple criteria roboxooo Linux - Newbie 6 01-15-2009 04:13 AM
can't find my find command! how to replace? dave247 Debian 4 11-19-2008 10:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:44 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
Open Source Consulting | Domain Registration