[nflug] copy (cp) large number of files
Jason Lasker
lasker at eng.buffalo.edu
Tue Apr 25 10:43:49 EDT 2006
I ran into this problem too and used a tar pipe to copy files...
tar -cf - directory | (cd parent; tar -xf -)
Check you tar options for the proper switches/parameters
Hope this helps
Jason Lasker
Senior Systems Administrator
Science and Engineering Node Services
University at Buffalo
113 Bell Hall
Buffalo, NY 14260-2050
Voice: (716) 645-3797 x2172
Fax (716) 645-3704
email mailto:lasker at eng.buffalo.edu
-----Original Message-----
From: nflug-bounces at nflug.org [mailto:nflug-bounces at nflug.org] On Behalf Of Robert Meyer
Sent: Tuesday, April 25, 2006 10:20 AM
To: nflug at nflug.org
Subject: Re: [nflug] copy (cp) large number of files
Nope, wrong answer. If it can't handle the '*' for an argument list, it also can't handle it as part of the 'for' loop. You will get the same error. I think the limit is 32767 characters.
Cheers!
Bob
--- joshj at linuxmail.org wrote:
>
> 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
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com _______________________________________________
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