我在 awk
中将时间戳转换为 EPOCH 秒,重复时间戳得到不正确的输出
输入:
20180614 00:00:00
20180614 00:00:23
20180614 22:45:00
20180614 22:45:21
20180614 00:00:00
20180614 00:00:23
预期输出:
1528930800
1528930823
1528930800
1529012721
1528930800
1528930823
我做到了
awk '{ ts="\""$0"\""; ("date +%s -d "ts)| getline epochsec; print epochsec}'
上面命令运行后的输出:
1528930800
1528930823
1529012700
1529012721
1529012721
1529012721
最佳答案
使用 GNU xargs:
xargs -I {} date +%s -d {} < file
输出:
1528927200 1528927223 1529009100 1529009121 1528927200 1528927223
关于unix - 在awk中将时间戳转换为EPOCH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50942962/