shell中的逻辑判断while

shell中的逻辑判断while_第1张图片

 

w|head -1|awk -F'load average: ' '{print $2}'|cut -d. -f1

 

#!/bin/bash

while true
do
load=`w|head -1|awk -F'load average: ' '{print $2}'|cut -d. -f1`
if [ $load -gt 10 ]
then
echo $load
fi
sleep 30
done

 

  

#!/bin/bash
while true
do
    read -p "Please input a number:" n

    if [ -z "$n" ]
    then
        echo "you need input sth"
        continue
     fi

     n1=`echo $n|sed 's/[0-9]//g'`
     if [ -n "$n1" ]
     then
        echo "you just only input numbers"
        continue
     fi

      break
done
echo $n

  

 

转载于:https://www.cnblogs.com/jzhg/p/8567596.html

你可能感兴趣的:(shell中的逻辑判断while)