dưới đây là định dạng trong một tập tin. bất cứ ai có thể giúp chuyển đổi hai cột đầu tiên ở định dạng ngày sang định dạng epoch?
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702058496,0,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702058496,2,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702058496,3,32,0,0,0,0,32,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702058496,4,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702062592,0,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702062592,2,0,0,0,0,919,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702062592,3,919,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702062592,4,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702066688,0,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702066688,2,0,0,0,0,0,0,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702066688,3,0,0,0,0,919,0,0
2018-01 / 02 05: 44: 00,2018-01 / 02 05: 59: 00,1,702066688,4,0,0,0,0,0,0,0,0
2018-01 / 02 10: 44: 00,2018-01 / 02 10: 59: 00,1,702058496,0,0,0,0,0,0,0,0,0
2018-01 / 02 10: 44: 00,2018-01 / 02 10: 59: 00,1,702058496,2,0,0,0,0,0,0,0,0
tôi đã thử với lệnh sau.
aa = cat ATMIF.180102-0615 |grep -|awk -F ',' '{print $1}'
; cho tôi vào cat ATMIF.180102-0615 |grep -|awk -F ',' '{print $1}'
; làm ngày -d "$ aa" "+% s"; làm xong
nhưng nó báo lỗi là: ngày: ngày không hợp lệ 2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 05:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00\n2018-01-02 10:44:00'
date: invalid date
2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05 : 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018 -01-02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018- 01/02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10:44 : 00 \ n2018-01 / 02 10:44:00 'ngày: ngày không hợp lệ `2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05:44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01- 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05: 44: 00 \ n2018-01 / 02 05:44:00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10:44:00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01- 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10: 44: 00 \ n2018-01 / 02 10:44:00 '
cat ATMIF.180102-0615 |grep -|awk -F ',' '{print $1}'
; cho tôi vàocat ATMIF.180102-0615 |grep -|awk -F ',' '{print $1}'
; làm ngày -d "$ aa" "+% s"; xong