Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jun 2004 13:23:01 +0200
From:      Henrik W Lund <henrik.w.lund@broadpark.no>
To:        =?ISO-8859-9?Q?Yavuz_Ma=FElak?= <bmalik@ihlas.net.tr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: copy or listing problem
Message-ID:  <40D2D095.1080702@broadpark.no>
In-Reply-To: <1e3201c45522$c393f840$dc96eed5@maslak>
References:  <1e3201c45522$c393f840$dc96eed5@maslak>

next in thread | previous in thread | raw e-mail | index | archive | help
Yavuz Maşlak wrote:
> Hello
> I use freebsd4.9
> I have thousands of files in my any directory. and I need to copy them to another directory. 
> but when I started to copy them I got error as below;
> /bin/cp: Argument list too long.
> 
> Do I have to copy them in pieces ?
> 
> What shall I do ?
> 
> Thanks 

Greetings!

You could do it with a shell script:

[SOF]
#!/bin/sh

for file in *
do
	if [ -f "$file" ]
	then
		cp "$file" "$target_dir" #Define $target_dir yourself
	fi
done
[EOF]

This will only do files, not directories or other special files. If you 
want to copy directories as well, the script will quickly grow bigger.

Read man sh for more (maybe even too much) info on how to do anything 
with scripts.

-Henrik W Lund



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?40D2D095.1080702>