ITPub博客

首页 > Linux操作系统 > Linux操作系统 > shell创建以当前日期时间为名字的目录

shell创建以当前日期时间为名字的目录

Linux操作系统 作者:wg0411 时间:2018-02-02 11:33:47 0 删除 编辑

很多时候我们要在脚本里自动创建带当前日期和时间的目录,用如下命令即可:

点击(此处)折叠或打开

  1. [root@iZ25b43k92fZ scripts]# more test.sh

  2. dirdate=`date +%Y%m%d`_`date +%H%M%S`
  3. mkdir $dirdate
[root@iZ25b43k92fZ scripts]# ls -ltr
drwxr-xr-x 2 root root  4096 Feb  4 15:03 20170204_150357

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29578568/viewspace-2150782/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-03-31

  • 博文量
    235
  • 访问量
    536113