【发布时间】:2020-07-22 01:16:04
【问题描述】:
我有一个字符串,其中包含我需要获取的信息,然后是一个我想删除的警告:
Time Sync Status: Local time: Mon 2020-04-06 19:25:43 EDT
Universal time: Mon 2020-04-06 23:25:43 UTC
RTC time: n/a
Time zone: America/New_York (EDT, -0400)
Network time on: no
NTP synchronized: no
RTC in local TZ: yes
Warning: This mode can not be fully supported. It will create various problems
with time zone changes and daylight saving time adjustments. The RTC
time is never updated, it relies on external facilities to maintain it.
If at all possible, use RTC in UTC by calling
'timedatectl set-local-rtc 0'.
所以我试图拆分“警告”上的字符串并在此之前获取文本......但我已经尝试了很多东西,但没有任何东西对我有用:
echo Time Sync Status: "$(timedatectl status | awk -F 'Warning' '{print $1}')"
我怎样才能做到这一点?
TIA 罗恩
【问题讨论】: