![]() |
|
Модераторы: powerfox, ZeeLax |
![]()
|
|
| Wowa |
|
|||
|
Эксперт Профиль Группа: Админ Сообщений: 15017 Регистрация: 14.9.2000 Где: Винград Репутация: нет Всего: 290 |
Как произвести поиск текста в файлах?
|
|||
|
||||
| *NS* |
|
|||
|
Опытный ![]() ![]() Профиль Группа: Участник Клуба Сообщений: 299 Регистрация: 26.3.2002 Репутация: нет Всего: нет |
man find
-------------------- ну, все, что знал - рассказал... |
|||
|
||||
| Wowa |
|
|||
|
Эксперт Профиль Группа: Админ Сообщений: 15017 Регистрация: 14.9.2000 Где: Винград Репутация: нет Всего: 290 |
Мне нужен пример. На man я и сам кого хочешь могу послать. |
|||
|
||||
| *NS* |
|
|||
|
Опытный ![]() ![]() Профиль Группа: Участник Клуба Сообщений: 299 Регистрация: 26.3.2002 Репутация: нет Всего: нет |
Finding files by content (searching for text strings in files) The standard utilities for searching text strings in files are grep/egrep for regular expression searches and fgrep to search for literal strings. To search for an expression in all files in the current directory just type: egrep -i "search expression" * To search for strings in all files down the directory tree you can combine the find or other file name search commands with e.g egrep. This can be done in several ways: egrep -i "expression" `find . -type f -print` find . -type f -exec egrep -i "expression" /dev/null {} \; find . -type f -print | xargs egrep -i "expression" If you find this hard to remember then you can just use a small shell script downloadable form here: grepfind.gz. The script makes also sure that non-printable characters are removed in case you egrep accidentally through a binary file. A very interesting search program is agrep. agrep works basically like egrep but does fault tolerant searches. This way you can also find slightly mis-spelled words. To search for an expression and allow for a maximum of 2 spelling errors you use: agrep -i -2 "search exprission" * The agrep program can be downloaded form sunsite sunsite.unc.edu/pub/Linux/utils/text/agrep-2.04.tar.Z or the original site ftp://ftp.cs.arizona.edu/agrep/ Then there is also glimpse. glimpse is a very powerful search utility. It uses a concept similar to locate. First a database needs to be build, but then searches are very fast. To build a search index for the contents of all files starting from the current directory: glimpseindex . After that you can search for a string in all files that were previously indexed glimpse -i -2 "search exprission" glimpse is also fault tolerant (as agrep) and the -2 allows for two errors. glimpse is available from http://glimpse.cs.arizona.edu/ -------------------------------------------------------------------------------- There are many search utilities available for Unix and Linux especially. This article can be by no means complete. If you are interested in more tricks and utilities like this then have a look at the .lsm files under http://sunsite.unc.edu/pub/Linux/utils Have fun, happy searching. -------------------- ну, все, что знал - рассказал... |
|||
|
||||
| Wowa |
|
|||
|
Эксперт Профиль Группа: Админ Сообщений: 15017 Регистрация: 14.9.2000 Где: Винград Репутация: нет Всего: 290 |
Вот и я о том же ;) Спасибо. |
|||
|
||||
![]()
|
| Правила форума "Linux/UNIX: Oбщие вопросы" | |
|
|
В тему здесь вопросы общие - не привязанные к определенному ПО или дистрибутиву BSD/Linux/UNIX.
За интересные статьи, находки, решения, программы и просто реальную помощь будут ставиться + в репу). В данный момент этот раздел модерируют nerezus, nickless, powerfox, pythonwin, Imple и ZeeLax. Если вы хотите помочь нам, пишите в ПМ и мы обсудим. Спасибо. И use UNIX or die; С уважением, nerezus, nickless, powerfox, pythonwin, Imple, ZeeLax. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | *NIX системы: Общие вопросы | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |