0
移动变量字符串(文件)我想问一下关于我下面的脚本一些帮助:bash脚本与通配符
#!/bin/bash
year=$(date +%Y)
lastyear=$((year-1))
month=$(date +%m)
log="$lastyear$month"
mkdir -p "/root/temp/$lastyear"
mkdir -p "/root/temp/$lastyear/$month"
cd /root
mv -f "*$log*" "/root/temp/$lastyear/$month"
错误提示是
mv: cannot stat `*201602*': No such file or directory
我的目标是将文件名中具有特定“201602”字符串的所有文件移动到特定位置。 采样日志文件是OUTXXX-201602XXX
,INXXX-201602XXX
,201602XXXX
。
这将通过crontab
执行,因为有大约500k +日志文件要传输,并且使用find将收到太多的参数错误T_T。
任何建议将有所帮助!
尝试过,但仍然是相同的错误提示 – mmstores
$ archivefolder =/root/temp忘记编辑该部分 – mmstores
注意:您不需要'mkdir -p“/ root/temp/$ lastyear”'命令,目录由'mkdir -p“/ root/temp/$ lastyear/$ month”'覆盖。 –