Lo que probé:
root@host [/home1]# cp -f hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C
Siempre me preguntan si quiero sobrescribir. Usar mv tampoco funciona. ¿Entonces qué debo hacer?
Otras cosas que probé:
root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C
root@host [/home1]# cp -force hello /home3
cp: invalid option -- 'o'
Try `cp --help' for more information.
root@host [/home1]# cp --remove-destination hello /home4
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination -r hello /home3
cp: overwrite `/home3/hello/.buildpath'? ^C
root@host [/home1]#

alias cp?type cpasí comols -len uno de los archivos de destino puede proporcionar información útil.Respuestas:
cpparece estar alias a algo que está causando problemas, o es una función. Puede eliminar el alias / función:Si prefiere anularlo ahora, puede usar el
commandcomando para anular cualquier alias / definición de función:Si prefiere eliminar esto por completo, es probable que tenga que buscar en los archivos de inicio de bash.
fuente
\cpTambién evitará el alias.which cp => alias cp='cp -i; /bin/cp. Gracias amazon!Para forzar la sobrescritura sin preguntar, debe usar el comando mv y la opción "-f", use man para ver las opciones.
hombre mv:
Ejemplo:
fuente
Pruebe cp -rv / sourcefileordirectory / Destinationfolder
fuente
-rvsignifica recursivo y detallado. Entonces esto debería copiar los archivos y subcarpetas, y enviar el progreso al terminal.Probablemente tenga un alias para cp. Puede anular este alias haciendo:
Esto tiene la ventaja de no modificar la configuración de su alias, ya que lo anula solo para esta llamada.
fuente
Puede usar
yes, que está diseñado para este tipo de cosas. Imprimiráyy responderá automáticamente estas indicaciones por usted:fuente
simplemente ejecute
alias cp=cpy sobrescribirá el objetivo sin preguntar en esta sesión. Si desea tenerlo almacenado como comportamiento estándar, guárdelo en su~/.bashrc.fuente