macOS High Sierra“日志显示”输出

macOS High Sierra“日志显示”输出

log showmacOS High Sierra 的命令输出详细信息如下:

**Command 1**
 log show --info --predicate 'eventMessage contains "system boot:"'

log: warning: ./system_logs.logarchive present but reading from system log store.
    Filtering the log data using "eventMessage CONTAINS "system boot:""
    Skipping debug messages, pass --debug to include.
    Timestamp                       Thread     Type        Activity             PID    TTL  
    2019-03-23 21:48:12.000000+0530 0x0        Timesync    0x0                  0      0    === system boot: F2089765-6B22-4EEA-B0A2-898726E1F57E
    2019-03-25 09:58:05.000000+0530 0x0        Timesync    0x0                  0      0    === system boot: 039103F9-8353-4344-A97E-38BB08EE8FFC
    2019-03-25 20:55:31.000000+0530 0x0        Timesync    0x0                  0      0    === system boot: A71B7566-88BB-4271-8437-454357766C51
    2019-03-26 09:58:04.000000+0530 0x0        Timesync    0x0                  0      0    === system boot: 29D9BC4A-E16D-4722-89C4-3D28155AEE73

log show使用以下内容过滤了命令输出:

**Command 2**
log show --info --predicate 'eventMessage contains "system boot:"'|awk 'BEGIN { OFS="\t"; print "Date(YYYY-MM-DD)","Time(IST)", "Type","\t Boot Message" } {print $1,$2,$4,$9,$10,$11}'|sed '2d'

输出:

log: warning: ./system_logs.logarchive present but reading from system log store.

Date(YYYY-MM-DD)    Time(IST)        Type        Boot Message
2019-03-23  21:48:12.000000+0530    Timesync    system  boot:   F2089765-6B22-4EEA-B0A2-898726E1F57E
2019-03-25  09:58:05.000000+0530    Timesync    system  boot:   039103F9-8353-4344-A97E-38BB08EE8FFC
2019-03-25  20:55:31.000000+0530    Timesync    system  boot:   A71B7566-88BB-4271-8437-454357766C51
2019-03-26  09:58:04.000000+0530    Timesync    system  boot:   29D9BC4A-E16D-4722-89C4-3D28155AEE73
2019-03-27  10:11:33.000000+0530    Timesync    system  boot:   A2D4C446-597D-468D-BD89-BD36008969CB
2019-03-27  20:48:38.000000+0530    Timesync    system  boot:   B4F5495F-DE8E-4669-8544-FE413479475D
2019-03-28  13:07:41.000000+0530    Timesync    system  boot:   8B745BF2-FE44-46F5-A0D1-B473CA105874
2019-03-29  09:57:59.000000+0530    Timesync    system  boot:   0496C812-683F-4AE0-ACA4-2450C9B5608C
2019-03-30  12:37:12.000000+0530    Timesync    system  boot:   8A999D8A-B4B2-4E1B-AA40-106D115C2E38
2019-04-01  10:09:12.000000+0530    Timesync    system  boot:   DD16C0BB-D717-4218-AF89-F31FC6D657E1

最好的选项是什么(awk|sed|cut|xargs 等):

  • 用于生成带下划线或最适合读者眼睛的任何格式的列名称。

  • 参考Command 2输出列-$9,$10,$11。我们如何减少$9,$10 & $11 之间的空间?

  • 使用sed '1d'不会删除第一行输出 -"log: warning: ./system_logs.logarchive present but reading from system log store."要么来自Command 1也不来自Command 2.如何解决这个问题?

  • log show命令需要一些时间(2-5 分钟)来解析统一日志。如何以百分比格式向用户显示这样的进度。

提前致谢。

相关内容