AIX 环境下取得昨天日期的 Shell
来源:互联网 发布:夏威夷果 知乎 编辑:程序博客网 时间:2024/05/21 23:01
<h1>我需要使用自动shell导出昨天的数据库内容,由于aix的ksh不支持date -d命令,不得不选择其他方式来实现。</h1>
#!/bin/ksh # Var Declare #!/bin/sh # ydate: A Bourne shell script that # prints yestarday's date # Output Form: Month Day Year # change by chenjy 20161026# Set the current month day and year. month=`date +%m`day=`date +%d`year=`date +%Y`# Add 0 to month. This is a # trick to make month an unpadded integer. month=`expr $month + 0`# Subtract one from the current day. day=`expr $day - 1`# If the day is 0 then determine the last # day of the previous month. if [ $day -eq 0 ]; then# Find the preivous month. month=`expr $month - 1`# If the month is 0 then it is Dec 31 of # the previous year. if [ $month -eq 0 ]; then month=12 day=31 year=`expr $year - 1`# If the month is not zero we need to find # the last day of the month. else case $month in 1|3|5|7|8|10|12) day=31;; 4|6|9|11) day=30;; 2) if ( [ `expr $year % 4` -eq 0 ] && [ `expr $year % 100` -ne 0 ] || [ `expr $year % 400` -eq 0 ] ) ; then day=29 else day=28 fi# if [ `expr $year % 400` -eq 0 ]; then # day=29 # fi ;; esacfificase $day in 1|2|3|4|5|6|7|8|9) day='0'$dayesaccase $month in 1|2|3|4|5|6|7|8|9) month='0'$monthesacecho $year$month$day
0 0
- AIX 环境下取得昨天日期的 Shell
- AIX环境下计算昨天日期的shell两例
- IBM AIX 下shell获取昨天的日期
- aix shell 获取昨天的日期
- hp-unix 取得昨天的日期 shell
- FreeBSD下取得昨天日期的方法
- 如何取得昨天的日期
- 转】c#取得昨天日期
- shell脚本获得昨天的日期
- java取得昨天和明天的格式化日期
- shell 获取昨天日期
- shell 取得上个月的开始结束日期
- 定制AIX操作系统的shell环境
- 定制AIX操作系统的shell环境
- Mac Shell获取昨天日期
- 汇总shell获取昨天日期
- linux中用shell获取昨天、明天或多天前的日期
- linux中用shell获取昨天、明天或多天前的日期
- 设置text-overflow: ellipsis后引起的文本对齐问题
- 3076 翻翻乐
- 深入浅出JMS(一)–JMS基本概念
- Weak vs. Strong Memory Models
- MongoDB学习总结--入门篇
- AIX 环境下取得昨天日期的 Shell
- 小知识点
- 深入浅出JMS(二)--ActiveMQ简单介绍以及安装
- ARMlinux kernel 启动之start_kernel (二)
- Array Dimensions
- Matlab中image、imagesc和imshow函数用法解析
- 《大数据时代》读书笔记——知道“是什么”就够了,没必要知道“为什么”。我们不必非得知道现象背后的原因,而是要让数据自己“发声”
- jersey2 MappableException 异常出现的情况
- Oracle SQL执行计划基线总结(SQL Plan Baseline)