To copy some files from one directory to another can be done kinda nicely with the find
command.
- First define the start date:
touch --date "2024-01-01" /tmp/start
- Define the end date:
touch --date "2024-02-01" /tmp/end
- Now simply craft a
find
command like this:
find /var/logs/some_dir -type f -newer /tmp/start -not -newer /tmp/end -exec cp "{}" /opt/another/directory \;
NOTE: In the above command, the -exec
part of the find uses "{}"
as where it puts each filename
when executing the command.