OS

date커멘드를 ISO8601/RFC2822/RFC3339형식으로 출력

lejpower 2023. 4. 7. 18:40

ISO8601

$ man date

-I[TIMESPEC], --iso-8601[=TIMESPEC]
output date/time in ISO 8601 format. TIMESPEC='date' for date only (the default), 'hours', 'minutes', 'seconds', or 'ns' for date and time to
the indicated precision.
$ date --iso-8601
2023-01-22

$ date --iso-8601=date
2023-01-22

$ date --iso-8601=hours
2023-01-22T14+0900

$ date --iso-8601=minutes
2023-01-22T14:01+0900

$ date --iso-8601=seconds
2023-01-22T14:01:16+0900

$ date --iso-8601=ns
2023-01-22T14:01:16,631109694+0900

 

RFC2822/RFC3339

 

-R, --rfc-2822
output date and time in RFC 2822 format. Example: Mon, 07 Aug 2006 12:34:56 -0600

--rfc-3339=TIMESPEC
output date and time in RFC 3339 format. TIMESPEC='date', 'seconds', or 'ns' for date and time to the indicated precision. Date and time com-
ponents are separated by a single space: 2006-08-07 12:34:56-06:00
--- date command output with RFC 2822 format ---
$ date --rfc-2822
Sun, 22 Jan 2023 14:12:25 +0900

--- date command output with RFC 3399 format ---
$ date --rfc-3339=date
2023-01-22

$ date --rfc-3339=seconds
2023-01-22 14:12:25+09:00

$ date --rfc-3339=ns
2023-01-22 14:12:25.698220571+09:00

'OS' 카테고리의 다른 글

[LINUX] 포트번호 지정해서 특정IP 커넥션 확인법  (0) 2021.11.10
regular expression library  (0) 2021.07.14