[nflug] copy (cp) large number of files

Sam Stern samstern at samstern.net
Tue Apr 25 05:11:59 EDT 2006


 

>-----Original Message-----
>From: nflug-bounces at nflug.org [mailto:nflug-bounces at nflug.org] 
>On Behalf Of Robert F. Stockdale IV
>Sent: Tuesday, April 25, 2006 04:53 AM
>To: Niagara Frontier Linux Users Group
>Subject: [nflug] copy (cp) large number of files
>
>Hello all:
>	I'm in the middle of reconfiguring my server. This box 
>now runs Gentoo with several scsi 
>drives. I have three drives that I'm using LVM2 to create 1 
>directory. This stores mostly music 
>and video files. In order not to loose any of the files I 
>created an LVM partition out of 2 18G 
>drives. I then formated this with mkreiserfs and mounted it. I 
>then tried to copy the nearly 
>full 36G ext3 drive to the newly created LVM drive. This is 
>with the intention of reformatting 
>the ext3 drive with reiserfs and using it to extend the LVM 
>partition. However, when I tried to 
>copy the files I got:
>
>cp /mnt/mus/multimedia/* /mnt/mus/
>-bash: /usr/bin/cp: Argument list too long
>
>	My son stop by and told me to use -R switch which did 
>work at copying. However, it also copied 
>the directory. I want to be able to mount this as 
>/mnt/multimedia and then create the 
>directories applicable for the files used. If left in the 
>current state it would mount ok but 
>instead of referring to the directory as /mnt/multimedia it would be 
>/mnt/multimedia/multimedia. So my question is: How can I get 
>these into the parent directory of 
>the LVM partition without the "-bash: /usr/bin/cp: Argument 
>list too long " error message?
>Thank you,
>Bob

Hi Bob,

Assuming I understand that you want to merge ALL the files under
/mnt/mus/multimedia/ into one directory called /mnt/multimedia then this
should do the trick:

 find /mnt/mus/multimedia -type f -exec cp {} /mnt/multimedia \;

Note well the ending of "\;" it's very important.

What this command does is locate all files (not directories or links) and
then copies each file, as it's found, into the new directory. It's a bit
slow but quite reliable.


HTH and good luck!

Sam S.

_______________________________________________
nflug mailing list
nflug at nflug.org
http://www.nflug.org/mailman/listinfo/nflug



More information about the nflug mailing list