You can pass --remove-source-files
to rsync to move files instead of copying them.
But in your case, there's no point in using rsync, since the destination is empty. A plain mv
will do the job as fast as possible.
In your case, what could make a difference to performance is the choice of network protocol, if you have a choice among NFS, Samba, sshfs, sftp, rsync over ssh, tar piped into ssh, etc. The relative speed of these methods depends on the file sizes, the network and disk bandwidth, and other factors, so there's no way to give general advice, you'll need to run your own benchmarks.
The POSIX standard only specifies that the response need to be "affirmative" for the copying to be carried out when -i
is in effect.
For GNU cp
,
the actual input at that point is handled by a function called yesno()
. This function is defined in the lib/yesno.c
file in the gnulib source distribution, and looks like this:
bool
yesno (void)
{
bool yes;
#if ENABLE_NLS
char *response = NULL;
size_t response_size = 0;
ssize_t response_len = getline (&response, &response_size, stdin);
if (response_len <= 0)
yes = false;
else
{
/* Remove EOL if present as that's not part of the matched response,
and not matched by $ for example. */
if (response[response_len - 1] == '\n')
response[response_len - 1] = '\0';
yes = (0 < rpmatch (response));
}
free (response);
#else
/* Test against "^[yY]", hardcoded to avoid requiring getline,
regex, and rpmatch. */
int c = getchar ();
yes = (c == 'y' || c == 'Y');
while (c != '\n' && c != EOF)
c = getchar ();
#endif
return yes;
}
If NLS ("National Language Support") is not used, you can see that the only reply that the function returns true for is a response that starts with an upper or lower case Y
character. Any additional or other input is discarded.
If NLS is used, the rpmatch()
function is called to determine whether the response was affirmative or not. The purpose of the rpmatch()
NLS library function is to determine whether a given string is affirmative or not (with support for internationalisation).
On BSD systems, the corresponding function is found in src/bin/cp/utils.c
:
/*
* If the file exists and we're interactive, verify with the user.
*/
int
copy_overwrite(void)
{
int ch, checkch;
if (iflag) {
(void)fprintf(stderr, "overwrite %s? ", to.p_path);
checkch = ch = getchar();
while (ch != '\n' && ch != EOF)
ch = getchar();
if (checkch != 'y' && checkch != 'Y')
return (0);
}
return 1;
}
This is essentially the same as the non-NLS code path in the GNU code.
Best Answer
cp
appears to be either aliased to something which is causing problems, or it is a function. You can remove the alias/function:If you'd rather just override it right now, you can use the
command
command to override any alias/function definitions:If you'd rather totally remove this, you probably have to look in your bash startup files.