User Tools

Site Tools


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

This is an old revision of the document!


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

tr

http://ru.wikipedia.org/wiki/Tr

$ cat /etc/passwd | tr ':' ' '

$ df -h / | tr -s ' '

cut

http://ru.wikipedia.org/wiki/Cut

$ cut -d: -f1 /etc/passwd
$ cut -d: -f1,7 /etc/passwd
$ cut -d: -f1-3 /etc/passwd
$ cut -c1-5 /etc/passwd

sort

http://ru.wikipedia.org/wiki/Sort

Ключи -n -r -u

grep

http://ru.wikipedia.org/wiki/Grep

$ grep root /etc/passwd

$ grep '^root' /etc/passwd

$ grep 'sh$' /etc/passwd

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

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

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

FreeBSD
/usr/local/etc/apache/httpd.conf

Linux
/etc/apache2/apache2.conf
/etc/apache2/sites-available/default-ssl
$ grep -v '^#' file
$ grep -v '^ *#' file
$ grep -v '^ *#\|^$' file

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

$ grep -vE '^ *#|^$' file

Примеры использования

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