I have to move some files from one folder to another, criteria set by a find and grep. When I try to move the files it breaks.
The actual move it's trying is mv /somefolder/export//somefolder/storage/testfileOLD.txt
What I expected was mv /somefolder/storage/testfileOLD.txt /somefolder/export/testfileOLD.txt
The command I'm using:
find /somefolder/storage/ -type f -name "*OLD*" -newermt '2019-05-1' ! -newermt '2019-06-7' -exec grep -qiF 'closed' {} \; -exec mv {} /somefolder/export/{} \;
I already tried with -exec basename {}
, this gives me the right result, but when I modify the mv to
-exec echo {} /somefolder/export/$(basename {}) \;
to check if it works it still gives me the /somefolder/export//somefolder/storage/testfileOLD.txt
.
{}
in destination formv
? It should work fine if you just leave it as-exec mv {} /somefolder/export/ \;