当前位置: 首页> 健康> 母婴 > seo网络优化公司排名_商标查询网站_杭州seo排名费用_查询收录

seo网络优化公司排名_商标查询网站_杭州seo排名费用_查询收录

时间:2025/7/10 12:58:14来源:https://blog.csdn.net/weimeilayer/article/details/143864009 浏览次数:0次
seo网络优化公司排名_商标查询网站_杭州seo排名费用_查询收录
vi  delete_exited_containers.sh
#!/bin/bash# 列出所有停止的容器并存储到数组
list_exited_containers() {echo -e "\nStopped containers:"containers=()# 获取停止的容器信息并存入数组while IFS= read -r line; docontainers+=("$line")done < <(docker ps -a --filter "status=exited" --format "{{.ID}} {{.Names}}")# 显示停止的容器列表for i in "${!containers[@]}"; doecho "[$i] ${containers[$i]}"done
}# 删除指定的容器
delete_containers() {local indexes=("$@")for index in "${indexes[@]}"; doif [[ $index =~ ^[0-9]+$ ]] && [[ $index -lt ${#containers[@]} ]]; thencontainer_info=${containers[$index]}container_id=$(echo "$container_info" | awk '{print $1}')echo "Deleting container: $container_info"docker rm "$container_id"elseecho "Invalid index: $index"fidone
}# 主逻辑
while true; dolist_exited_containersif [[ ${#containers[@]} -eq 0 ]]; thenecho "No stopped containers to delete."breakfi# 获取用户输入echo -e "\nEnter indexes of containers to delete (space-separated), or type 'all' to delete all, or 'exit' to quit:"read -r inputif [[ "$input" == "exit" ]]; thenecho "Exiting..."breakelif [[ "$input" == "all" ]]; then# 删除所有容器for i in "${!containers[@]}"; docontainer_id=$(echo "${containers[$i]}" | awk '{print $1}')echo "Deleting container: ${containers[$i]}"docker rm "$container_id"doneecho "All stopped containers deleted."else# 使用下标删除指定的容器IFS=' ' read -r -a indexes <<< "$input"delete_containers "${indexes[@]}"fiecho -e "\nOperation complete. Would you like to continue? (yes/no):"read -r continue_inputif [[ "$continue_input" != "yes" ]]; thenecho "Exiting..."breakfi
done

赋予执行权限

chmod +x delete_containers_by_index.sh

运行脚本

./delete_containers_by_index.sh

在这里插入图片描述
输入下标,然后输入yes确认删除

0
yes
关键字:seo网络优化公司排名_商标查询网站_杭州seo排名费用_查询收录

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: