gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 10:05:22 26 4
gpt4 key购买 nike

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

最佳答案

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

关于linux - 将每月的 linux 文件移动到另一个文件夹脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53006042/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com