두 번째와 세 번째 열에 신기원과 난수가 있는 아래와 같은 입력이 있습니다. awk 내장 함수 strftime()을 사용하여 epoch 날짜를 변환하고 epoch 값에 없는 값을 바꾸려고 합니다.
아래를 사용해 보았지만 원하는 결과를 얻지 못했습니다.
awk '{ print $1 strftime("%c",$2) strftime("%c",$3) }' test.txt
입력하다:-
h_RTGUSEQ_RTY_FILE_LIST_ODRF_XOB 0 0 11
TRF_RTGUSFX_RTY_FILE_LIST_XOB 0 0 11
TRF_RTGUSIG_RTY_FILE_LIST_XOB 0 0 11
NGU_AVM_DAILY_SCHEDULE_XOB 1617804000 1617804156 7
TRF_RTGUSIR_RTY_FILE_LIST_XOB 0 0 11
NGU_schedule_next 1614198958 1614198979 7
TCR_RTGUSCR_DSTGE_REPORT_XOB 1591171200 1591171268 7
YUI_RTGNLEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11
NGU_schedule_current 1614198946 1614198957 7
YUI_RTGNLEQ_Z_DUMMY_XOB 0 0 7
YUI_RTGNLEQ_Z_TRIGR_DSJ_XOB 0 0 11
YUI_RTGSGEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11
예상되는출력 샘플 형식: epoch 값을 동일한 파일에 언급된 형식의 날짜로 바꿔야 합니다.
h_RTGUSEQ_RTY_FILE_LIST_ODRF_XOB 0 0 11
TRF_RTGUSFX_RTY_FILE_LIST_XOB 0 0 11
TRF_RTGUSIG_RTY_FILE_LIST_XOB 0 0 11
NGU_AVM_DAILY_SCHEDULE_XOB 07 Apr 2021 09:04:00 AM 07 Apr 2021 09:04:36 AM 7
TRF_RTGUSIR_RTY_FILE_LIST_XOB 0 0 11
NGU_schedule_next 24 Feb 2021 02:02:58 PM 24 Feb 2021 02:02:19 PM 7
TCR_RTGUSCR_DSTGE_REPORT_XOB 03 Jun 2020 03:06:00 AM 03 Jun 2020 03:06:08 AM 7
YUI_RTGNLEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11
NGU_schedule_current 24 Feb 2021 02:02:46 PM 24 Feb 2021 02:02:57 PM 7
YUI_RTGNLEQ_Z_DUMMY_XOB 0 0 7
YUI_RTGNLEQ_Z_TRIGR_DSJ_XOB 0 0 11
YUI_RTGSGEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11
답변1
$ awk -v OFS='\t' '{
for (i=2; i<=3; i++) {
$i = ($i ? strftime("%d %b %Y %r",$i) : $i)
}
print
}' test.txt | column -s$'\t' -t
h_RTGUSEQ_RTY_FILE_LIST_ODRF_XOB 0 0 11
TRF_RTGUSFX_RTY_FILE_LIST_XOB 0 0 11
TRF_RTGUSIG_RTY_FILE_LIST_XOB 0 0 11
NGU_AVM_DAILY_SCHEDULE_XOB 07 Apr 2021 09:04:00 AM 07 Apr 2021 09:04:36 AM 7
TRF_RTGUSIR_RTY_FILE_LIST_XOB 0 0 11
NGU_schedule_next 24 Feb 2021 02:02:58 PM 24 Feb 2021 02:02:19 PM 7
TCR_RTGUSCR_DSTGE_REPORT_XOB 03 Jun 2020 03:06:00 AM 03 Jun 2020 03:06:08 AM 7
YUI_RTGNLEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11
NGU_schedule_current 24 Feb 2021 02:02:46 PM 24 Feb 2021 02:02:57 PM 7
YUI_RTGNLEQ_Z_DUMMY_XOB 0 0 7
YUI_RTGNLEQ_Z_TRIGR_DSJ_XOB 0 0 11
YUI_RTGSGEQ_DB_CHK_RTYCYCLE_ARCHV_XOB 0 0 11