在以前版本的 CentOS 上,我使用以下命令在我的 bash 脚本中获取当前时区:
timezone=$(sed 's/ZONE=//g' /etc/sysconfig/clock)
输出是 "America/New_York"
"America/New_York"
如何在 CentOS 7 上获得准确的输出?
sed centos timezone
centos ×1
sed ×1
timezone ×1