From 2ddc1b51298f4cee7fa7812732a577061cbddfb4 Mon Sep 17 00:00:00 2001 From: lsy Date: Tue, 19 Nov 2024 16:43:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=8C=96=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E7=AE=A1=E7=90=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/Automation/manage.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Config/Automation/manage.sh b/Config/Automation/manage.sh index 7b71828..e252b9b 100644 --- a/Config/Automation/manage.sh +++ b/Config/Automation/manage.sh @@ -20,16 +20,16 @@ function list_scripts() { declare -a installed_scripts declare script_name declare script_count=0 - for script in "$script_directory"/* ; do - if [[ $script == "${script_directory}/*" ]];then + for script in "$script_directory"/*; do + if [[ $script == "${script_directory}/*" ]]; then echo "该目录没有脚本" exit fi - script_name=$(awk -F '.' '{print $1}' <<< "$(basename $script)") + script_name=$(awk -F '.' '{print $1}' <<<"$(basename $script)") if [[ $script_name == "linuxtool" ]]; then continue fi - script_count=$(( script_count+1 )) + script_count=$((script_count + 1)) echo "${script_count}.${script_name}" installed_scripts[$script_count]=$script_name done @@ -47,13 +47,13 @@ case $user_choice in '2') installed_scripts=($(list_scripts)) read -p "请输入要删除的序号(多个用空格隔开):" script_name - for i in $script_name ; do + for i in $script_name; do if [[ $i =~ [1-${#installed_scripts[@]}] ]]; then echo "开始删除 ${installed_scripts[$i]}" (crontab -l 2>/dev/null | grep -v "${installed_scripts[$i]}") | crontab - && echo "已删除脚本的自动任务" - rm -rf "$script_directory/${installed_scripts[$i]}" &> /dev/null + rm -rf "$script_directory/${installed_scripts[$i]}" &>/dev/null echo "删除完成" fi done ;; -esac \ No newline at end of file +esac