No puedes usar rsync --delete
así. No tiene estado y no guarda ningún registro de qué archivos se han eliminado entre ejecuciones. El indicador --delete
simplemente indica a rsync
que elimine todos los archivos del destino que no existan en el origen.
Para implementar esta eliminación restringida, creo que necesita mantener su propio estado. Ni rsync
ni unison
pueden hacer esto por usted.
La siguiente no es una solución completa segura -de error; es un punto de partida. (Sin embargo, maneja archivos con nombres extraños -incluidos aquellos que contienen una nueva línea incrustada.)
Suponga dos directorios src
y dst
. (A los efectos del ejemplo, realmente no importa si dst
es local o remoto.)
# Find the current list of files (do this just once, to prep the cache)
( cd src && find. -type f -print0 ) | LC_ALL=C sort -z >.state.src
Cada vez que realicemos una copia de seguridad, ejecute el siguiente código
# Run the rsync to transfer files. "dst/" could be local
rsync -av src/ remote:dst/
# Determine the set of files to delete in "dst/"
( cd src && find. -type f -print0 ) | LC_ALL=C sort -z | tee.state.src.new |
LC_ALL=C comm -z - -13.state.src |
ssh remote 'while IFS= read -d "" -r f; do rm -f "dst/$f"; done'
# That seemed to work, so update the state cache
[[ 0 -eq $? ]] && mv -f.state.src.new.state.src
Si su versión decomm
(como la mía )es anterior a GNU coreutils 8.25 y no tiene el indicador -z
, puede usar esta solución alternativa:
# Find the current list of files (do this just once, to prep the cache)
( cd src && find. -type f -print0 ) | tr '\0\n' '\n\0' | LC_ALL=C sort >.state.src
Cada vez que realicemos una copia de seguridad, ejecute el siguiente código
# Run the rsync to transfer files. "dst/" could be local
rsync -av src/ remote:dst/
# Determine the set of files to delete in "dst/"
( cd src && find. -type f -print0 ) | tr '\0\n' '\n\0' | LC_ALL=C sort | tee.state.src.new |
LC_ALL=C comm -13 -.state.src |
tr '\0\n' '\n\0' |
ssh remote 'while IFS= read -d "" -r f; do rm -f "dst/$f"; done'
# That seemed to work, so update the state cache
[[ 0 -eq $? ]] && mv -f.state.src.new.state.src
Я почти уверен, что вы не можете сделать это в nano
. Самое близкое, что вы могли бы получить, это перенос строк, а именно «мягкий перенос»:Esc + $ .
Это перенесет строки, чтобы вы могли видеть их все на экране.
Источник:https://www.nano-editor.org/dist/v2.9/nano.html(поиск --софтвер)
Вы можете получить такое поведение с помощью vim
, однако редактор более настраиваемый. См.:https://ddrscott.github.io/blog/2016/sidescroll/