From ac115ae8c22a659b2f0150a092effa0405443322 Mon Sep 17 00:00:00 2001 From: xzx3344521 Date: Tue, 28 Oct 2025 14:02:09 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E6=B5=8B=E9=80=9F=E4=B8=AD=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 测速中文 | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/测速中文 b/测速中文 index 8c9643e..c1e0cc9 100644 --- a/测速中文 +++ b/测速中文 @@ -1,19 +1,12 @@ #!/bin/bash -echo "🌐 网络速度测试" -echo "正在启动..." - -# 直接运行测速,不下载文件 -result=$(curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 - --simple 2>/dev/null) - -if [ $? -ne 0 ] || [ -z "$result" ]; then - echo "❌ 测速失败,请检查网络连接" - exit 1 -fi - -# 快速解析结果 -echo "✅ 测试完成:" -echo "$result" | awk ' -/Ping:/ {printf "🔄 延迟: %s %s\n", $2, $3} -/Download:/ {printf "⬇️ 下载: %s %s\n", $2, $3} -/Upload:/ {printf "⬆️ 上传: %s %s\n", $2, $3} -' +echo "🌐 开始测速..." +{ + curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 - --simple +} 2>/dev/null | while IFS= read -r line; do + case $line in + *Ping:*) echo "🔄 延迟: ${line#*:}" ;; + *Download:*) echo "⬇️ 下载: ${line#*:}" ;; + *Upload:*) echo "⬆️ 上传: ${line#*:}" ;; + esac +done +echo "✅ 完成"