使用grep -c 可以统计每个文件匹配模式的数量,通过这种方法可以抽取出不匹配模式的那些文件,因为不包含匹配模式的文件将显示为file:0
vgrep()
{ case $# in
0|1) echo "Usage: `basename $0` pattern file [files...]" 1>&2
;;
*) pattern = $1
shift
grep -c $pattern "$@" |sed -n ‘s/:0$//p‘
;; esac
}原文地址:http://darksun.blog.51cto.com/3874064/1558330