shell脚本时间操作
来源:互联网 发布:linux远程连接xrdp 编辑:程序博客网 时间:2024/05/19 20:37
http://blog.csdn.net/cws1214/article/details/27681189
date +%s 可以得到UNIX的时间戳;
用shell将时间字符串与时间戳互转:
date -d “2010-10-18 00:00:00” +%s 输出形如:1287331200
而时间戳转换为字符串可以这样做:
date -d @1287331200 “+%Y-%m-%d” 输出形如:2010-10-18
如果需要得到指定日期的前后几天,可以:
1、seconds=date -d "2010-10-18 00:00:00" +%s
#得到时间戳
2、seconds_new=expr $seconds + 86400
#加上一天的秒数86400
3、date_new=date -d @$seconds_new "+%Y-%m-%d"
#获得指定日前加上一天的日前 等同于 date -d “1970-01-01 UTC “3423423234” seconds” +”%Y-%m-%d %H:%M:%S”
date -d”-500years” 等同于date –date=”500 years ago”
date -d”500years ago”
2个月3天之后可以这样写:
date -d”+2month+3day”
0 0
- shell脚本时间操作
- shell脚本时间操作
- shell 脚本中的时间操作
- shell脚本专家指南--日期时间操作
- shell脚本-有关时间的操作
- shell 脚本 时间
- 【SHELL脚本】文件操作
- shell脚本文件操作
- shell脚本操作数据库
- shell脚本字符串操作
- shell脚本操作数据库
- Java操作shell脚本
- 常用shell脚本操作
- shell操作数据库脚本
- shell脚本操作mysql
- shell脚本操作oracle
- shell 脚本日期操作
- shell 脚本字符串操作
- spark集群安装和基本使用
- 学 Win32 汇编[28] - 跳转指令: JMP、JECXZ、JA、JB、JG、JL、JE、JZ、JS、JC、JO、JP 等
- 1096. Consecutive Factors (20)
- Git Community Book 中文版 rebase
- 剑指offer33
- shell脚本时间操作
- jdk不同版本对String拼接的优化分析
- do{...}while(0)的意义和用法
- 转-Memcache知识点梳理
- 2016年我所涉足的技术栈大盘点
- JNI学习
- 多表链接 Left join
- 选好”车轮”
- Android 日常开发技术经验 60 条