UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 16th, 2006, 11:31 AM
dnagirl's Avatar
dnagirl dnagirl is offline
data transfer technician
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: Halifax, NS
Posts: 469 dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 19 h 10 m 48 sec
Reputation Power: 57
Cat foo|xargs -I {} find {} -exec ... AGHHH!

Hi All,

I have a file 'sqlout' that is a list of 1000 file names. I need to go through a directory structure with 10's of thousands of files and copy only the ones in sqlout to another directory.

Code:
cat sqlout|xargs -I [] find . -name [] -exec cp {} /target \;

works but it's awfully slow. I've added some restrictions to find (like -type f and others) but it hasn't helped with the speed. Any magic way that this can happen faster?

Tx,
Jennifer

Reply With Quote
  #2  
Old February 17th, 2006, 10:36 AM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 815 Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 5 h 43 m 48 sec
Reputation Power: 243
Are you sure you are not vastly over-egging the pudding here? Some questions: are all the files in the same source directory? does the sqlout file contain a full path or just name?

What would be taking the time (apart from the actual I/O of the copy) is the 1,000 find commands you are doing. That would be the thing to aim to get rid of if you could.

Reply With Quote
  #3  
Old February 17th, 2006, 01:37 PM
dnagirl's Avatar
dnagirl dnagirl is offline
data transfer technician
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Location: Halifax, NS
Posts: 469 dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level)dnagirl User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 19 h 10 m 48 sec
Reputation Power: 57
the files are all in different directories
the filelist is just the file name because I don't know where the files are.
:sigh:

I guess I'm stuck with the slow way. Thanks for clarifying the problem.

Cheers,
Jennifer

Reply With Quote
  #4  
Old February 20th, 2006, 01:53 PM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 815 Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 5 h 43 m 48 sec
Reputation Power: 243
A bit of a pain, but if that is what you have tthen that is what you have and you have to work with it.

The only thing I can think of is to ensure that (since you are using find .) you are in the lowest level common directory of where the files can be found (assuming and hoping there is one - other than /).

Reply With Quote
  #5  
Old February 21st, 2006, 10:37 AM
playskool playskool is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 48 playskool Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 23 h 5 m 35 sec
Reputation Power: 0
Assuming that you built the sqlout from some criteria, couldn't you just find your way through the directory tree and print the file name?

IE

find . | xargs grep slqoutCriteria > outputFile

Seems like your are grabbing a filename from your file and finding that file in the directory tree. Like you're not shorting your find.

Hope I understand you right....

Reply With Quote
  #6  
Old February 22nd, 2006, 07:00 AM
Ehlanna's Avatar
Ehlanna Ehlanna is offline
Not a clue what to put ...
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: in front of this keyboard
Posts: 815 Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level)Ehlanna User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 2 Weeks 2 Days 5 h 43 m 48 sec
Reputation Power: 243
To, possibly, improve the speed - cut down the iterations of the find command. Thus, do the comamnd just the once, save the results, then interrogate that file.

So, working with what my assumption of the requirement is, we get:

Code:
bd=`pwd`
ts=/tmp/cpy.sh
of=/tmp/fl.tmp
cat /dev/null > $ts
find . -type f > $of
for x in `cat sqlout`
do
  grep "\/${x}$" $of | cut -c2- | awk -v b=$bd '{printf("cp %s%s /target\n",b,$1)}' >> $ts
done
sh $ts

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Cat foo|xargs -I {} find {} -exec ... AGHHH!


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT