Grepは空白の区切り文字を理解していませんか?

Grepは空白の区切り文字を理解していませんか?

次の例では:

apt-file search apache2.conf | grep -E "apache2.conf\b"

出力:

apache2: /etc/apache2/apache2.conf
apache2-doc: /usr/share/doc/apache2-doc/examples/apache2/apache2.conf.gz
dicoweb: /etc/dicoweb/apache2.conf
emboss-explorer: /etc/apache2/conf-available/emboss-explorer.apache2.conf
emboss-explorer: /etc/emboss-explorer/apache2.conf
icinga-cgi: /usr/share/doc/icinga-cgi/examples/apache2.conf
icinga-cgi: /usr/share/icinga/apache2.conf
icinga2-classicui: /etc/icinga2-classicui/apache2.conf
kopano-webapp-apache2: /etc/apache2/conf-available/kopano-webapp-apache2.conf
kopano-webapp-apache2: /etc/kopano/webapp/apache2.conf
lacme: /etc/lacme/apache2.conf
lemonldap-ng-handler: /etc/apache2/sites-available/handler-apache2.conf
libjs-twitter-bootstrap: /usr/share/twitter-bootstrap/apache2.conf
liblemonldap-ng-manager-perl: /etc/apache2/sites-available/manager-apache2.conf
liblemonldap-ng-portal-perl: /etc/apache2/sites-available/portal-apache2.conf
mirmon: /usr/share/doc/mirmon/examples/mirror-apache2.conf
nagios3-cgi: /usr/share/nagios3-cgi/apache2.conf
oar-restful-api: /usr/share/oar/oar-api/apache2.conf
octopussy: /etc/octopussy/apache2.conf
spip: /usr/share/doc/spip/apache2.conf

単語の境界で理解し、次の行をマージしてみgrepてください。\b

apache2-doc: /usr/share/doc/apache2-doc/examples/apache2/apache2.conf.gz

拡張()バージョンがあるかどうかにかかわらず、-E同じ結果が表示されますgrep

ベストアンサー1

単語の境界単語文字から単語以外の文字への変換です。これは単語文字から空白への変換とは異なります。

からman grep

単語を構成する文字は、文字、数字、下線です。

.単語以外の文字はconf\bconf後ろ」が続くので一致します.

おすすめ記事