# grep -v 是指除掉带双引号中字符的那一行数据
#awk 默认按空格截取参数 $2就是拿第二个参数
pid_ram=`ps aux | grep /usr/java/tomcat | grep -v "grep" | grep -v "0\.0" | awk '{print $2}'`
ram=`ps aux | grep /usr/java/tomcat | grep -v "grep" | grep -v "0\.0" | awk '{print $4}'`
awk如果不指定分隔符的话,-F来指定分割符,默认以空格分割,你比如: echo "aaa bbb" | awk '{print $2}' 结果为bbb echo "aaa|bbb" | awk -F '|' '{print $2}' 结果为bbb (责任编辑:IT) |