1.条件判断: if 使用: if condition; then commands; fi if else 使用: if condition; then commands; else if condition; then commands; else commands; fi 说明: if和else语句可以进行嵌套.if的条件判断部分可能会变得很长, 但可以用逻辑运算符将它变得简洁一些: [ condition ] && action; # 如果condition为真,则执行acti…
#!/bin/bash SUM=0 OVERALL=0 for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"` do PID=`echo $DIR | cut -d / -f 3` PROGNAME=`ps -p $PID -o comm --no-headers` for SWAP in `grep Swap $DIR/smaps 2>/dev/null | awk '{ …