Re: Using grep



On 2006-02-27, Fernando Rodríguez wrote:

Hi,

How can I make grep return all the files that do NOT match a given pattern?

Files do not match (or NOT match) a pattern; lines within the file
do (or do not).

I'd like to have a list f all files that do NOT contain the text "addCookies".

for file in *
do
grep "addCookies" "$file" > /dev/null 2>&1 || printf "%s\n" "$file"
done

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.