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
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
相关文章推荐
- Java文件夹操作,判断多级路径是否存在,不存在就创建(包括windows和linux下的路径字符分析),兼容Windows和Linux
- [Script]采用Python创建当前日期文件夹
- 用DOS命令创建以当前日期为名称的文件夹
- 删除指定创建日期前的文件夹、文件
- c++创建文件夹多级目录
- VMare中安装“功能增强工具”,实现CentOS5.5与win7host共享文件夹的创建
- 最简单的创建多级目录文件夹
- 用批处理方式自动动创建以日期命名的文件夹
- 基于CentOS的Mysql学习补充二--使用Shell创建数据库
- 在ASP中自动创建多级文件夹的函数(使用FSO)
- 在Android Shell的根目录下创建文件夹
- PHP创建多级文件夹
- 在ios中的Document中创建多级文件夹以及文件
- ASP创建多级无限文件夹
- vb 多级路径创建,读取文件或文件夹[vb类写法]
- php文件上传判断类型创建多级文件夹
- VMare中安装“功能增强工具”,实现CentOS5.5与win7host共享文件夹的创建
- centos下vsftpd不能显示文件,不能创建文件及文件夹
- 一个以当前日期名创建文件夹的程序
- centos下vsftpd登录后无法看见文件,无法创建文件及文件夹