如何通过shell将文本文件中的日期格式更改为24小时。
cat data.txt
/stem/1 sts1033 08/29/2022 09:05:48 PM OX crN 51 Backup
/stem/2 sts1033 09/05/2022 09:05:18 PM OY crN 507 Backup
/stem/3 sts1033 09/12/2022 09:16:14 PM OX crN 5123 Backup
预期输出-
/stem/1 sts1033 08/29/2022 21:05:48 OX crN 51 Backup
/stem/2 sts1033 09/05/2022 21:05:18 OY crN 507 Backup
/stem/3 sts1033 09/12/2022 21:16:14 OX crN 5123 Backup
使用dateutils
:
dateconv -S -i '%m/%d/%Y %I:%M:%S %p' -f '%m/%d/%Y %H:%M:%S' < infile
输出:
/stem/1 sts1033 08/29/2022 21:05:48 OX crN 51 Backup
/stem/2 sts1033 09/05/2022 21:05:18 OY crN 507 Backup
/stem/3 sts1033 09/12/2022 21:16:14 OX crN 5123 Backup