linux date 查看系统时间与使用参数生成时间戳
        【摘要】  ECS信息规格:2vCPUs | 4GiB | kc1.large.2镜像:openEuler 20.03 64bit with ARM | 公共镜像  linux date 查看系统时间与使用参数生成时间戳 date 查看系统时间# dateSat Oct  2 21:53:40 CST 2021  date 使用参数生成时间戳# date "+%Y%m%d-%H%M%S"2021100...
    
    
    
    ECS信息
- 规格:2vCPUs | 4GiB | kc1.large.2
 - 镜像:openEuler 20.03 64bit with ARM | 公共镜像
 
linux date 查看系统时间与使用参数生成时间戳
date 查看系统时间
# date
Sat Oct  2 21:53:40 CST 2021
 
 
date 使用参数生成时间戳
# date "+%Y%m%d-%H%M%S"
20211002-215830
 
 - %Y year
 - %m month (01…12)
 - %d day of month (e.g., 01)
 - %H hour (00…23)
 - %M minute (00…59)
 - %S second (00…60)
 
使用date生成的时间戳 作为新建文件的名称
# touch $(date "+%Y%m%d-%H%M%S").txt
# ll
total 0
-rw------- 1 root root 0 Oct  2 22:02 20211002-220229.txt
 
 
帮助文档(部分)
# date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING          display time described by STRING, not 'now'
      --debug                annotate the parsed date,
                              and warn about questionable usage to stderr
  -f, --file=DATEFILE        like --date; once for each line of DATEFILE
  -I[FMT], --iso-8601[=FMT]  output date/time in ISO 8601 format.
......部分截取
 
 
学习资料
欢迎各位同学一起来交流学习心得^_^
            【声明】本内容来自华为云开发者社区博主,不代表华为云及华为云开发者社区的观点和立场。转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息,否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
                cloudbbs@huaweicloud.com
                
            
        
        
        
        
        
        
        - 点赞
 - 收藏
 - 关注作者
 
            
           
评论(0)