Linux Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsLinux 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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old May 21st, 2002, 09:38 AM
chinook chinook is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 262 chinook User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 58 sec
Reputation Power: 8
Help ! Too many files to mv / cp

Hello,

I have a very large number of files in a directory which i need to move - I'm running Suse Linux.

If I try cp or mv or even zip, I'm told that there are too many arguments to process the command....

Any ideas how I can move these?

Reply With Quote
  #2  
Old May 21st, 2002, 12:22 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
hi!
you can copy them one after the other like this:
Code:
for i in *; do mv "$i" /tmp/`basename $i`; done

though it could give you the same error. if so, try this:

Code:
find . -exec "mv {$1} /tmp/`basename {$1}`"

where i am not sure about the "{$1}".
see "man find" which the parameter for substitution is.

be sure to copy all quotes! i am not 100% sure if they all are right, so do some testing with filenames with spaces(!)

disclaimer: i take no responsibility if you end up destroying all your data!
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Last edited by M.Hirsch : May 21st, 2002 at 12:24 PM.

Reply With Quote
  #3  
Old May 21st, 2002, 03:29 PM
justice41 justice41 is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Emerald City
Posts: 289 justice41 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
You could also try, from the directory containg your files,
Code:
tar cf - * | (cd /path/to/newdir/ ; tar xfp - )

although i have never tested this for a very large number of files. I don't know what tar's limitations are compared to cp or mv.

jaa

Last edited by justice41 : May 21st, 2002 at 03:31 PM.

Reply With Quote
  #4  
Old May 21st, 2002, 03:34 PM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,969 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 39 m 55 sec
Reputation Power: 184
i think the limitation is on the shell or linux kernel itself, not on cp. (but not 100% sure...)

chinook, can you post your results after you tried please?

Reply With Quote
  #5  
Old May 21st, 2002, 04:36 PM
justice41 justice41 is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Emerald City
Posts: 289 justice41 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Yes, you are right.
See here http://www.linuxjournal.com/article.php?sid=6060 for solutions (some of which are in earlier post above)

jaa

Reply With Quote
  #6  
Old May 22nd, 2002, 03:48 AM
chinook chinook is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: London, England
Posts: 262 chinook User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 26 m 58 sec
Reputation Power: 8
Hi,

I found this page http://www.linuxjournal.com/article.php?sid=6060 which had a few different methods. The one that I used did actually take quite a long time to mv (5 minutes). I used a function:

function large_mv ()
{ while read line1; do
mv directory/$line1 ../directory2
done
}

ls -1 directory/ | large_mv

Cheers for the replies!

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsLinux Help > Help ! Too many files to mv / cp


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 3 hosted by Hostway