您的位置:首页 > 运维架构 > Shell

Centos7.4 用shell创建以日期为名的多级文件夹

2018-03-20 14:32 393 查看
脚本如下:currenttime=$(date +%Y%m%d%H%M%S);
echo "current time $currenttime";

currentyear=$(date +%Y);
echo "current year:$currentyear";

currentmonth=$(date +%m);
echo "current month:$currentmonth";

currentday=$(date +%d);
echo "current day:$currentday";

hostname=`hostname`;
echo "this is hostname:$hostname";
path= "/cloud/log/$currentyear/$currentmonth/$currentday"
if [ -d "/cloud/log/$currentyear/$currentmonth/$currentday/"  ];then
    echo "the dir[/cloud/log/$currentyear/$currentmonth/$currentday/ ] is exit"
else
    mkdir -p /cloud/log/$currentyear/$currentmonth/$currentday/
fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: