User Tools

Site Tools


команда_фильтр_grep

This is an old revision of the document!


Команда фильтр grep

Шаблон

grep регулярное_выражение [имя_файла]''

Примеры

$ grep root /etc/passwd

$ ps -ax | grep init

$ tail –f /var/log/maillog | grep init

$ grep '^root' /etc/passwd

$ grep 'sh$' /etc/passwd

Ключ -r - рекурсивный перебор подкаталогов

$ grep -r '\<sed\>' /usr/share | more

Ключ -v - показать строки, не совпадающие с шаблоном

$ grep -v '^#' /etc/defaults/rc.conf | more

$ grep -v '^#\|^$' /etc/defaults/rc.conf | more

Ключ -E - использовать расширенные регулярные выражения

$ grep -vE '^#|^$' /etc/defaults/rc.conf | more

$ egrep -v '^#|^$' /etc/defaults/rc.conf | more

$ egrep -v '^ *#|^$' /usr/local/etc/apache/httpd.conf | more

команда_фильтр_grep.1235986256.txt.gz · Last modified: 2013/05/22 13:50 (external edit)