1- # tf - command-line time formatter
1+ # tf - CLI Unix Time formatter
22
3- ` tf ` scans for epoch times in input and outputs them
3+ ` tf ` scans for UNIX epoch times in input and outputs them
44as human readable strings to stdout.
55
66```
77$ cat log.txt
88[1524241219] Time is on my side
99[1555777220] Yes it is
10- [1587399621] A time in ecpoch millis: 1637419929123
11- [1618935621] A time in ecpoch nanos: 1637419929123456789
10+ [1587399621] A time in epoch millis: 1637419929123
11+ [1618935621] A time in epoch nanos: 1637419929123456789
1212
1313$ tf -g log.txt
1414[12:20:19] Time is on my side
1515[12:20:20] Yes it is
16- [12:20:21] A time in ecpoch millis: 09:52:09.123
17- [12:20:21] A time in ecpoch nanos: 09:52:09.123456789
16+ [12:20:21] A time in epoch millis: 09:52:09.123
17+ [12:20:21] A time in epoch nanos: 09:52:09.123456789
1818```
1919
2020## Usage
2121
2222```
2323$ tf --help
24- usage: ./ tf <options> [file1 [file2 [...]]]
24+ usage: tf <options> [file1 [file2 [...]]]
2525
26- Time Formatter
26+ UNIX Time Formatter (tf)
2727
28- Scans for epoch times in input and outputs them
28+ Scans for UNIX epoch times in input and outputs them
2929as human readable strings to stdout.
3030
313110-digits are interpreted as seconds, 13 as milliseconds,
@@ -34,18 +34,18 @@ as human readable strings to stdout.
3434If no filenames or only '-' is passed, stdin is processed.
3535
3636examples:
37- $ echo 1637421447 | tf
38- $ tf -g log.txt | head
37+ $ echo 1637421447 | tf
38+ $ tf -g log.txt | head
3939
4040The time formatting uses Golang Time.Format layouts:
4141 https://pkg.go.dev/time#Time.Format
4242
4343options:
4444 -b, --block use block buffering (default: line buffering)
4545 -z, --block-size uint32 block buffer size (default 4096)
46- -d, --date default format with date: '2006-01-02 15:04:05'
47- -f, --format string golang Time.Format string (default: '15:04:05')
48- -g, --global global match
46+ -d, --date output with date, same as --format '2006-01-02 15:04:05'
47+ -f, --format string output with Golang Time.Format layout (default: '15:04:05')
48+ -g, --global global match (default: convert only first match in line)
4949 -h, --help show help
5050```
5151
@@ -71,35 +71,35 @@ Raw log:
7171$ cat log.txt
7272[1524241219] Time is on my side
7373[1555777220] Yes it is
74- [1587399621] A time in ecpoch millis: 1637419929123
75- [1618935621] A time in ecpoch nanos: 1637419929123456789
74+ [1587399621] A time in epoch millis: 1637419929123
75+ [1618935621] A time in epoch nanos: 1637419929123456789
7676```
7777
7878Basic usage, piping from ` stdin ` :
7979```
8080$ cat log.txt | tf
8181[12:20:19] Time is on my side
8282[12:20:20] Yes it is
83- [12:20:21] A time in ecpoch millis: 1637419929123
84- [12:20:21] A time in ecpoch nanos: 1637419929123456789
83+ [12:20:21] A time in epoch millis: 1637419929123
84+ [12:20:21] A time in epoch nanos: 1637419929123456789
8585```
8686
8787Date conversion:
8888```
8989$ tf -d log.txt
9090[2018-04-20 12:20:19] Time is on my side
9191[2019-04-20 12:20:20] Yes it is
92- [2020-04-20 12:20:21] A time in ecpoch millis: 1637419929123
93- [2021-04-20 12:20:21] A time in ecpoch nanos: 1637419929123456789
92+ [2020-04-20 12:20:21] A time in epoch millis: 1637419929123
93+ [2021-04-20 12:20:21] A time in epoch nanos: 1637419929123456789
9494````
9595
9696Global match, converting sub-second times:
9797```
9898$ tf -gd log.txt
9999[ 2018-04-20 12:20:19] Time is on my side
100100[ 2019-04-20 12:20:20] Yes it is
101- [ 2020-04-20 12:20:21] A time in ecpoch millis: 2021-11-20 09:52:09.123
102- [ 2021-04-20 12:20:21] A time in ecpoch nanos: 2021-11-20 09:52:09.123456789
101+ [ 2020-04-20 12:20:21] A time in epoch millis: 2021-11-20 09:52:09.123
102+ [ 2021-04-20 12:20:21] A time in epoch nanos: 2021-11-20 09:52:09.123456789
103103```
104104----
105105
0 commit comments