Taking Grep to a Lower Level

Startseite
Anhänge:
Nachricht
+ (text/plain)
Nachricht löschen
Nachricht beantworten
Autor: G.D.Thurman
Datum:  
Betreff: Taking Grep to a Lower Level
# list the name of files containing the pattern foo
# should work on sh, bash and ksh

for fname in `find . -type f 2>/dev/null` ; do
file $fname 2>/dev/null | grep text 1>/dev/null 2>&1 && grep -l foo $fname
done

# manpage for 'file' indicates that most files that can be displayed
# on a screen will have the word "text in their description