linux&shell日常脚本命令之if判断

  1. shell脚本if中判断大于、小于、等于、不等于的符号

    脚本有问题,有没有哪位大佬能帮忙检查一下?
bash 复制代码
#!/bin/bash

#run_num=$(squeue | grep shifting | wc -l)
run_num=`squeue | grep shifting | wc -l`
#run_num=$(squeue | grep shifting | wc -l 2>&1)

while true;do
    #if [ $(echo "$run_num") -eq 0 ];then
        for i in $(seq 2 9);do
            name=$(printf len300_0%d $i)
            cd $name || exit 1
            #model_num=$(ls *model.pdb | wc -l)
            model_num=$(ls -l *model.pdb 2>/dev/null | wc -l)
            if [ $(echo "$model_num") -eq 1200 ];then
                cd ../ || exit 1
            elif [ $(echo "$model_num") -eq 0 ]&&[ $(echo "$run_num") -le 197 ];then
                #filepath=$(pwd)
                cd Submit
                nohup python submit.py & 
                cd ../../
            fi
        done
    #fi       
    sleep 300
done    
bash 复制代码
#!/bin/bash


while true; do
    folder_completed=false

    for i in $(seq 2 9); do
        name=$(printf len300_0%d $i)
        cd $name || exit 1

        model_num=$(ls -l *model.pdb 2>/dev/null | wc -l)

        run_num=$(squeue | grep shifting | wc -l)
        if [ "$model_num" -eq 1200 ]; then
            cd ../ || exit 1
            folder_completed=true
            break  # 终止内层循环,避免继续检查其他文件夹
        elif [ "$model_num" -eq 0 ] && [ "$run_num" -le 197 ]; then
            cd Submit
            nohup python submit.py &
            cd ../../
            folder_completed=true
            break  # 终止内层循环,避免继续检查其他文件夹
        fi

        #cd ../ || exit 1
    done

    # 如果当前文件夹已完成,就不要进行休眠和外层循环的下一次迭代
    if [ "$folder_completed" = true ]; then
        continue
    fi

    sleep 1800
done
相关推荐
L0208249 小时前
Kubernetes Ingress|CNI 网络模型|Calico 网络策略|Pod 调度器完整实战教程
运维·网络·云原生·容器·kubernetes
考拉讲支付11 小时前
延迟分账 / 核销分账的技术实现方案:服务完成后再分钱,到底怎么设计?
大数据·运维·人工智能·微信小程序·小程序·系统架构
ADAI_Bowen11 小时前
写文章 - 知乎
大数据·运维·人工智能
GeW12 小时前
新质生产力路线图解读:数据库性能优化与Linux调优专场
linux
云宏信息12 小时前
超融合和存算分离怎么选?从性能、可靠性、扩展、成本四个维度讲述如何精准匹配架构选型 | 附企业降本轻量云方案
运维·服务器·架构·云计算
mounter62512 小时前
深入理解 gccrs:GCC 如何实现 Rust 编译器,以及编译 Linux 内核面临的挑战
linux·驱动开发·rust
垚垚学技术_聚焦云原生12 小时前
Ansible Playbook 进阶:when 条件、loop 循环、handlers 触发器落地
linux·ansible·自动化运维·devops
无足鸟ICT13 小时前
【RHCA+】type命令(判断命令类型)
linux·ssh·bash
咸鱼梦想家π13 小时前
Linux开发工具(下)
linux·运维·服务器