shell 实现获取当前时间,并进行格式转换的方法:
1)原格式输出
2018年 09月 30日 星期日 15:55:15 CST
time1=$(date)
echo $time1
2)时间串输出
20180930155515
1 #!bin/bash 2 time2=$(date "+%Y%m%d%H%M%S") 3 echo $time2
3)2018-09-30 15:55:15
#!bin/bash time3=$(date "+%Y-%m-%d %H:%M:%S") echo $time3
4)2018.09.30
#!bin/bash time4=$(date "+%Y.%m.%d") echo $time4
注意
1、date后面有一个空格,shell对空格要求严格
2、变量赋值前后不要有空格
3、解释
1 Y显示4位年份,如:2018;y显示2位年份,如:18。 2 m表示月份;M表示分钟。 3 d表示天;D则表示当前日期,如:1/18/18(也就是2018.1.18)。 4 H表示小时,而h显示月份。 5 s显示当前秒钟,单位为毫秒;S显示当前秒钟,单位为秒。
Prisma 2 is Coming Soon
amundsen 来自lyft 的开源数据发现平台
packr 方便的潜入静态资源文件到golang 二进制文件中
hasura skor 构建安装
Oracle中删除用户下所有对象的多种方法
负载均衡----实现配置篇(Nginx)
【nginx】配置Nginx实现负载均衡
Vmware ESXi添加共享磁盘
从Oracle迁移到MySQL的各种坑及自救方案
- 最新文章
-
circus security 来自官方的安全建议
circus && web comsole docker-compose 独立部署
circus web console 依赖tornado>3.2 无法访问的bug
circus 做为批处理的守护进程
circus 架构
sphinx doc 文档生成脚手架工具
circus docker image web 运行异常问题的解决
circus 进程以及socket 管理工具&&docker运行
a list of frequently asked questions about Circus
python 微服务开发书中几个方便的python框架
- 热门文章
-
Collecting metrics with the PostgreSQL and TimescaleDB output plugin for Telegraf
dbt 0.13.0 新添加特性sources 试用
apisix 基于openresty 的api 网关
testinfra 基础设施测试工具
tox 试用
tox python项目虚拟环境管理自动化测试&&构建工具
puppeteer 试用
My journey introducing the data build tool (dbt) in project’s analytical stacks
comlink 是来自google chrome 团队的简化webwokers 开发的类库
graphql-inspector graphql schema比较&&文档校验&&查找破坏性变动工具
Copyright © 2011-2022 走看看