最近偶为了写一个调整时间的shell而绞尽脑汁,结果在某一天
#info data
这里面看到了data -d参数的灵活用法,真是欣喜若狂。好东西要保存,整理整理:

* To print the date of the day before yesterday:

date --date='2 days ago'

* To print the date of the day three months and one day hence:

date --date='3 months 1 day'

* To print the day of year of Christmas in the current year:

date --date='25 Dec' +%j

* To print the current full month name and the day of the month:

date '+%B %d'

But this may not be what you want because for the first nine days
     of the month, the `%d' expands to a zero-padded two-digit field,
     for example `date -d 1may '+%B %d'' will print `May 01'.

* To print a date without the leading zero for one-digit days of the
     month, you can use the (GNU extension) `-' flag to suppress the
     padding altogether:

date -d 1may '+%B %-d

* To print the current date and time in the format required by many
     non-GNU versions of `date' when setting the system clock:

date +%m%d%H%M%Y.%S

* To set the system clock forward by two minutes:

date --set='+2 minutes'

* To print the date in RFC 2822 format, use `date --rfc-2822'.  Here
     is some example output:

Fri, 09 Sep 2005 13:51:39 -0700

* To convert a date string to the number of seconds since the epoch
     (which is 1970-01-01 00:00:00 UTC), use the `--date' option with
     the `%s' format.  That can be useful in sorting and/or graphing
     and/or comparing data by date.  The following command outputs the
     number of the seconds since the epoch for the time two minutes
     after the epoch:

date --date='1970-01-01 00:02:00 +0000' +%s
          
          date --date='1970-01-01 00:02:00 +0000' +%s
          120

If you do not specify time zone information in the date string,
     `date' uses your computer's idea of the time zone when
     interpreting the string.  For example, if your computer's time
     zone is that of Cambridge, Massachusetts, which was then 5 hours
     (i.e., 18,000 seconds) behind UTC:

# local time zone used
          date --date='1970-01-01 00:02:00' +%s
          18120

* If you're sorting or graphing dated data, your raw date values may
     be represented as seconds since the epoch.  But few people can
     look at the date `946684800' and casually note "Oh, that's the
     first second of the year 2000 in Greenwich, England."

date --date='2000-01-01 UTC' +%s
          946684800

An alternative is to use the `--utc' (`-u') option.  Then you may
     omit `UTC' from the date string.  Although this produces the same
     result for `%s' and many other format sequences, with a time zone
     offset different from zero, it would give a different result for
     zone-dependent formats like `%z'.

date -u --date=2000-01-01 +%s
          946684800

To convert such an unwieldy number of seconds back to a more
     readable form, use a command like this:

# local time zone used
          date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z"
          1999-12-31 19:00:00 -0500

Often it is better to output UTC-relative date and time:

date -u -d '1970-01-01 946684800 seconds' +"%Y-%m-%d %T %z"
          2000-01-01 00:00:00 +0000

linux date -d参数用法的更多相关文章

  1. [转帖]Linux date命令的用法(转)

    Linux date命令的用法(转) https://www.cnblogs.com/asxe/p/9317811.html 1.命令:date 2.命令功能:date 可以用来显示或设定系统的日期与 ...

  2. Linux date命令的用法(转)

    1.命令:date 2.命令功能:date 可以用来显示或设定系统的日期与时间. 3.命令参数 -d<字符串>:显示字符串所指的日期与时间.字符串前后必须加上双引号: -s<字符串& ...

  3. Linux date命令的用法

    在linux shell编程中,经常用到日期的加减运算以前都是自己通过expr函数计算,很麻烦.其实date命令本身提供了日期的加减运算非常方便. 例如:得到昨天的时间date  --date=&qu ...

  4. 11.Linux date命令的用法

    date命令常的日常应用   修改时间 date -s “2008/05/23 19:20″ 打包文件 tar zcvf log-$(date +$F).gz /home/admin/logs 同步阿 ...

  5. linux mount命令参数及用法详解

    linux mount命令参数及用法详解 非原创,主要来自 http://www.360doc.com/content/13/0608/14/12600778_291501907.shtml. htt ...

  6. 【转】linux expr命令参数及用法详解

    在抓包过程中,查看某个设定时间内,数据上下行多少,用命令expr 计算! --------------------------------------------------------------- ...

  7. linux dmesg命令参数及用法详解(linux显示开机信息命令)

    linux dmesg命令参数及用法详解(linux显示开机信息命令) http://blog.csdn.net/zhongyhc/article/details/8909905 功能说明:显示开机信 ...

  8. linux sed命令参数及用法详解

    linux sed命令参数及用法详解 http://blog.csdn.net/namecyf/article/details/7336308 1. Sed简介 sed 是一种在线编辑器,它一次处理一 ...

  9. linux scp命令参数及用法详解--linux远程复制拷贝命令使用实例【转】

    转自:http://blog.csdn.net/jiangkai_nju/article/details/7338177 一般情况,本地网络跟远程网络进行数据交抱,或者数据迁移,常用的有三种方法,一是 ...

随机推荐

  1. python查看文件的编码格式

    pip install chardet 执行 import chardet f = open('a.doc',r) data = f.read() print chardet.detect(data) ...

  2. UI基础:UILabel.UIFont 分类: iOS学习-UI 2015-07-01 19:38 107人阅读 评论(0) 收藏

    UILabel:标签 继承自UIView ,在UIView基础上扩充了显示文本的功能.(文本框) UILabel的使用步骤 1.创建控件 UILabel *aLabel=[[UILabel alloc ...

  3. PyCharm 注释

    1.1 单行注释(行注释) 语法格式: #[空格]说明性文字信息 注:可放一行代码的后面进行说明 添加快捷键:  Ctrl+/ 取消快捷键:  同上 1.2 多行注释(块注释) 语法格式: " ...

  4. iOS-----使用NSURLConnection

    使用NSURLConnection 如果只是为了读取HTTP等服务器数据,或向服务器提交数据,iOS还提供了NSURLConnection类,NSURLConnection使用NSURLRequest ...

  5. C++ 泛型 编写的 数据结构 队列

    平时编程里经常需要用到数据结构,比如  栈和队列 等,  为了避免每次用到都需要重新编写的麻烦现将  C++ 编写的 数据结构 队列  记录下来,以备后用. 将 数据结构  队列  用头文件的形式写成 ...

  6. DelaunayTriangulation_VoronoiDiagram_using_OpenCV的实现

    前言 最近project中有关于delaunay的实现问题,查找资料,看到learnopencv这个网站,有很多peoject的实现,本文主要是实现Delaunay Triangulation and ...

  7. Mr. Kitayuta's Colorful Graph CodeForces - 506D(均摊复杂度)

    Mr. Kitayuta has just bought an undirected graph with n vertices and m edges. The vertices of the gr ...

  8. POJ 3617:Best Cow Line(贪心,字典序)

    Best Cow Line Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30684   Accepted: 8185 De ...

  9. 字符串的比较【string和字符数组】

    无论是string 还是 字符数组的字符串比较函数,返回的都是字典序的大小.如 1234 和 5 比较时就是1234的字典序小于5,要想比较字符串表示的数字的大小,需要自己写函数比较

  10. day32 多进程

    一 multiprocessing模块介绍 python中的多线程无法利用多核优势,如果想要充分地使用多核CPU的资源(os.cpu_count()查看),在python中大部分情况需要使用多进程. ...