[20200417]xdate別名.txt
[20200417]xdate別名.txt
--//工作需要,需要一個1970/1/1 + 微秒轉換為時間的命令。
--//1微秒等於一百萬分之一秒(10-6秒),oracle dump 輸出有這樣的時間格式:
PARSING IN CURSOR #139947943262104 len=2282 dep=0 uid=103 oct=3 lid=103 tim=1587138705191190 hv=635489653 ad='133982f160' sqlid='0pv15fhky1mbp'
PARSING IN CURSOR #139947943262104 len=2282 dep=0 uid=103 oct=3 lid=103 tim=1587138705212785 hv=635489653 ad='133982f160' sqlid='0pv15fhky1mbp'
PARSING IN CURSOR #139947943262104 len=2282 dep=0 uid=103 oct=3 lid=103 tim=1587138705234708 hv=635489653 ad='133982f160' sqlid='0pv15fhky1mbp'
# cat /usr/local/bin/xdate
#! /bin/bash
date -d "1970-01-01 00:00:00 UTC $( echo "scale=6; $1/1000000" |bc -l) seconds" +"%Y-%m-%d %T.%N"
date -d "@$( echo "scale=6; $1/1000000" |bc -l)" +"%Y-%m-%d %T.%N"
$ xdate 1587092504567446
2020-04-17 11:01:44.567446000
2020-04-17 11:01:44.567446000
--//第2種格式我不熟悉,也不知道,看別人這樣寫也是ok的。我了man date文件也沒有發現,僅僅存在info文件。
$info date
--//打入斜線查詢Epoc
28 Date input formats
*********************
First, a quote:
Our units of temporal measurement, from seconds on up to months,
are so complicated, asymmetrical and disjunctive so as to make
coherent mental reckoning in time all but impossible. Indeed, had
some tyrannical god contrived to enslave our minds to time, to
make it all but impossible for us to escape subjection to sodden
routines and unpleasant surprises, he could hardly have done
better than handing down our present system. It is like a set of
trapezoidal building blocks, with no vertical or horizontal
surfaces, like a language in which the simplest thought demands
ornate constructions, useless particles and lengthy
circumlocutions. Unlike the more successful patterns of language
and science, which enable us to face experience boldly or at least
level-headedly, our system of temporal calculation silently and
persistently encourages our terror of time.
... It is as though architects had to measure length in feet,
width in meters and height in ells; as though basic instruction
manuals demanded a knowledge of five different languages. It is
no wonder then that we often look into our own immediate past or
future, last Tuesday or a week from Sunday, with feelings of
helpless confusion. ...
-- Robert Grudin, `Time and the Art of Living'.
This section describes the textual date representations that GNU
programs accept. These are the strings you, as a user, can supply as
arguments to the various programs. The C interface (via the `get_date'
function) is not described here.
* Menu:
* General date syntax:: Common rules.
* Calendar date items:: 19 Dec 1994.
* Time of day items:: 9:20pm.
* Time zone items:: EST, PDT, GMT.
* Day of week items:: Monday and others.
* Relative items in date strings:: next tuesday, 2 years ago.
* Pure numbers in date strings:: 19931219, 1440.
* Seconds since the Epoch:: @1078100502.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Specifying time zone rules:: TZ="America/New_York", TZ="UTC0".
* Authors of get_date:: Bellovin, Eggert, Salz, Berets, et al.
--//順便學習一下如何將man與info文件轉換為文字方式 。
--//man文件,例子:
--// man cat | col -b > cat.txt
$ info date -s -o /tmp/date.txt
info: Writing node (coreutils.info.gz)date invocation...
info: Writing node (coreutils.info.gz)Time conversion specifiers...
info: Writing node (coreutils.info.gz)Date conversion specifiers...
info: Writing node (coreutils.info.gz)Literal conversion specifiers...
info: Writing node (coreutils.info.gz)Padding and other flags...
info: Writing node (coreutils.info.gz)Setting the time...
info: Writing node (coreutils.info.gz)Options for date...
info: Writing node (coreutils.info.gz)Examples of date...
info: Done.
$ date -d @1587092504.567446 +"%Y-%m-%d %T.%N"
2020-04-17 11:01:44.567446000
--//最後修改如下:
# cat /usr/local/bin/xdate
#! /bin/bash
# date -d "1970-01-01 00:00:00 UTC $( echo "scale=6; $1/1000000" |bc -l) seconds" +"%Y-%m-%d %T.%N"
date -d "@$( echo "scale=6; $1/1000000" |bc -l)" +"%Y-%m-%d %T.%N"
# chmod 755 /usr/local/bin/xdate
$ xdate 1587138705234708
2020-04-17 23:51:45.234708000
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2687103/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20200214]xargs與別名.txt
- [20191128]date命令別名.txt
- [20211213]完善date命令別名.txt
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視.txtSQL
- [20200417]跟蹤特定sql語句以及v$open_cursor檢視2.txtSQL
- [20180702]物件名重用.txt物件
- Windows修改新建.txt檔名Windows
- [20220329]批量修改檔名.txt
- [2020528]寫sql語句不要忘記給欄位加上表別名.txtSQL
- yii別名的定義和別名的獲取以及別名的使用
- [20211020]XXXX_DGB服務名.txt
- 模板別名
- TypeScript type 型別別名TypeScript型別
- [20200109]主機名如何定位IP.txt
- [20191219]索引名裡帶回車符.txt索引
- vscode配置別名VSCode
- SQL Server 別名(as)SQLServer
- [Git] 別名(alias)Git
- TypeScript 強大的型別別名TypeScript型別
- MyBatis-02-別名MyBatis
- Laravel Sail別名配置LaravelAI
- [20210913]bash shell $* and $@ 的區別.txt
- [20211123]sqlplus @與@@的區別.txtSQL
- vue3 配置 @ 別名Vue
- php: 操作elasticsearch的別名PHPElasticsearch
- 1.5 - Laravel 5.6 - Alias 別名Laravel
- Linux-別名設定Linux
- Git定義命令別名Git
- [20190612]NULL的資料型別.txtNull資料型別
- ssh別名登陸小技巧
- SpringBoot 引數別名實現Spring Boot
- Linux基礎命令---alias別名Linux
- 不可或缺的 Bash 別名
- 命令別名:保護和服務
- Mac 上 ssh 別名登入Mac
- 使用別名訪問MSSQL ExpressSQLExpress
- [20190531]lob型別pctversion 和 retention.txt型別
- 檔案型別和副檔名型別