Sunday Blog

人生是一场刻意练习

常用shell命令整理

Common Shell

# 通过此命令查看内存被哪些进程占用(单位是 MByte),输出 PID 与内存占用大小,通过 PID 可以找到对应进程 for i in `cd /proc;ls | grep "^[0-9]" | awk '$0 >100'` ;do awk '/Swap:/{a=a+$2}END{print '"$i"',a/1024"M"}' /proc/$i/smaps ;done 2>&1 |

Shell判断输入变量或者参数是否为空

Shell Judge Empty

判断变量为空 if [ ! -n "$word" ] ;then echo "you have not input a word" else echo "the word you input is $word" fi 直接判断 if [ ! "$word" ] ;then echo "you have not input a word" else echo "the word you input is $word" fi 使用test判断 if test -z "$word" ;then echo "you