将每月的linux文件移动到另一个文件夹脚本

时间:2018-10-26 09:51:27

标签: linux

sorry but I'm a beginner in Linux script commands.

我正在尝试每月在现有月份的每个第26天将文件自动传输到另一个文件夹。(Linux系统)     如果有人可以帮忙,我将不胜感激!     预先谢谢你!

I have files with this format xxxxx_181025.txt. I want them to be moved in another folder every 26th day of month.(but only files generated for actual month, in this case October.   I need some help on how to specify that only files of existing month should be moved?


cd /actual folder
_Y='%Y'
_y='%Y'
_m='%m'
_d='%d'
TIMESTAMP=`date "+$_Y$_m$_d"`
mv xxxxx_$TIMESTAMP   /new folder/xxxxx_$TIMESTAMP 
done

1 个答案:

答案 0 :(得分:0)

find /actual_folder -t f -mtime -26 -exec mv {} /new_folder/ \;