On 01/15/2018 09:00 AM, jdd@dodin.org wrote:
I can't make it work.
find . -type f ! -newermt 2017-01-01
or
find `pwd` -type f ! -newermt 2017-01-01
gives me files names from which I can't make a link
may be because some file names are odd
/data-ssd480/mesdocs-jdd/livres/cal/Dick,Philip K_/L'oeil dans le ciel (763)/L'oeil dans le ciel - Dick,Philip K_.epub
you have blanks and other special characters in file names. The only safe way to handle this between tool is to use NUL-terminated strings.
but also ln problems
find . -type f ! -newermt 2017-01-01 -exec ln "{}" "/data-ssd480/tmp/{}" \;
gives:
ln: impossible de créer le lien direct '/data-ssd480/tmp/./culte/mulet-reborn.bk/etc/sysconfig/mail' → './culte/mulet-reborn.bk/etc/sysconfig/mail': Aucun fichier ou dossier de ce type
AFAIR my French, this means that the parent directory in the target does not exist. I'm surprised why so many guys here suggest creating a hierarchy with hardlinks with the files falling in the year range. Well, you could also store it in a database, or write it on a paper and send it around the world before processing further. ;-) As I already wrote: - let find create a NUL-terminated list of files from e.g. 2013: $ cd DIR $ find . -type f -newermt 2013-01-01 ! -newermt 2014-01-01 -print0 > list - let e.g. copy the files from the list to the backup medium: $ mkdir BACKUP/2013 $ rsync -HAXaxv --from0 --files-from='list' '.' BACKUP/2013/. - remove the files from the source (after you have checked the backup): $ xargs -0 rm -v < 'list' Isn't this what you want? Actually that is just like moving, but ensuring that the directory structure is the same on the target. The following does the same with find/xargs/mkdir/mv: $ ( # gather list cd src \ && find . -type f -newermt 2013-01-01 ! -newermt 2014-01-01 -print0 \ ) | xargs -0 sh -c ' # move each file to dst, keeping the dir structure. while [ "$1" ]; do d="$(dirname "$1")" \ && mkdir -pv "dst/$d" \ && mv -v "src/$1" "dst/$d" \ && shift 1 \ || exit 255; # make xargs stop further processing done' ARCHIVE Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org