#!/bin/bash
ls > file
cat file | while read line
do
temp=`jarsigner -verify -verbose -certs $line | grep "xxx"`
if [ ! -z "$temp" ]; then
echo $line
fi
done
rm -f file
exit 0
注意变量赋值时等号与变量名、语句中间不可以有空格
在if条件判断中记得方括号[]及判断符、变量之间加空格
#!/bin/bash
ls > file
cat file | while read line
do
jarsigner -verify -verbose -certs $line | grep "huaqin" > /dev/null
temp=$?
if [ $temp -eq 0 ]; then
echo $line
fi
done
rm -f file
exit 0
使用temp=$?来接收上一条命令的执行结果 grep若是搜到结果则返回1 未搜到结果则返回0
/dev/null来将本该输出在命令窗中的内容进行放置到系统的null文件中 及此笔结果会消失不见