tylko pliki tekstowe grep
find . -type f | xargs file | grep text | cut -d':' -f1 | xargs grep -l "TEXTSEARCH" {}
To dobre rozwiązanie? dla find TEXTSEARCH recursively in only textual files 42
Author: StefanoCudini, 2012-03-21
2 answers
Możesz użyć opcji -r
(recursive) i -I
(ignore binary) w grep
:
$ grep -rI "TEXTSEARCH" .
-I
przetwarza plik binarny tak, jakby nie zawierał pasujących danych; jest to równoważne opcji--binary-files=without-match
.-r
Read all files under each directory, recursively; this is equivalent to the-d recurse
option.
172
Author: kev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-15 10:29:44
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-15 10:29:44
Innym, mniej eleganckim rozwiązaniem niż kevs, jest, łańcuchowo-exec polecenia w find razem, bez xargs i cut:
find . -type f -exec bash -c "file -bi {} | grep -q text" \; -exec grep TEXTSEARCH {} ";"
5
Author: user unknown,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-22 09:20:18
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-03-22 09:20:18