Linux find command and copy and rename them same time
You can do:
find /src -type f -name '*.log' -size +2G -exec cp {} /dest/{}-$(date -I) \;
Additions/Modifications i made:
-name '*.log'
searches only for log files, as we are only interested in those. You can look for files with any names too if unsure, just omit-name '*.log
in that case$(date -I)
is command substitution the output will be today's date in formatYYYY-mm-dd
, you can also define a custom format, checkman date
End the
-exec
action offind
with\;