Taking Grep to a Lower Level

トップ ページ
添付ファイル:
Eメールのメッセージ
+ (text/plain)
このメッセージを削除
このメッセージに返信
著者: G.D.Thurman
日付:  
題目: 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