#!/bin/sh # 时区列表 timezones=( "Asia/Shanghai" "Asia/Ho_Chi_Minh" "Asia/Calcutta" "Asia/Tokyo" "Asia/Seoul" "UTC" ) echo "上海时区" echo "越南时区" echo "印度时区" echo "日本时区" echo "韩国时区" echo "UTC 0" # 显示时区列表 echo "请选择一个时区:" for i in "${!timezones[@]}"; do echo "$i) ${timezones[$i]}" done # 读取用户输入 read -p "选择: " chosen_timezone # 检查输入是否有效 if [ "$chosen_timezone" -ge 0 ] && [ "$chosen_timezone" -lt ${#timezones[@]} ]; then # 设置时区 sudo timedatectl set-timezone ${timezones[$chosen_timezone]} echo "时区已更改为: ${timezones[$chosen_timezone]}" else echo "无效的选择." fi
标签:UTC,chosen,timezones,Asia,echo,UTC0,Linux,增删,timezone From: https://www.cnblogs.com/ywxkhym/p/18220877