[nflug] copy (cp) large number of files

joshj at linuxmail.org joshj at linuxmail.org
Tue Apr 25 10:11:42 EDT 2006


Thus spake Robert F. Stockdale IV on Tue, 25 Apr 2006

> 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

If you have files foo1 foo2 and foo3 in a directory and you do:

ls *

That is the same thing as typing

ls foo1 foo2 foo3

Its the bash that interprets the "*" into all the files so the program
(ls in this case) can understand it. There is an upper-limit to how many
'file arguments' you are allowed on the command line. Its quite a lot
though. So the trick is to feed each file, one at a time, to the
command. The shell is perfectly capable of this:

for file in /olddir/*; do
 	cp -R $file /newdir
done


-Josh

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



More information about the nflug mailing list