Записки криворукого админа
  • Записки криворукого админа
  • SaltStack
    • State
      • Name active interface
      • watch, require, *_in
    • Salt-api
      • tokens
    • ERROR
      • No module named tornado.stack_context
      • Got a bad pillar from master
  • Jinja
    • Last comma
  • Python
    • проверка версии модуля
  • Gitlab
    • Example values CI
    • gitlab multi pipeline
  • Linux
    • qemu/kvm
    • Cron all user
    • OpenVPN GUI
    • Group Linux
    • passwd
    • Systemctl
    • chmod для взрослых ;)
    • Comand0s
      • disck
      • grep
      • link
      • mkdir
    • Supervisor
    • Изменение hostname
    • WiFi - broadcom
    • cockpit
    • Viber
    • Время в терминале
    • Chmod
    • Docker ?
    • Тмух
    • Количество ядер
  • Utility
    • scp
      • zsh: no matches found
    • rsyslog
      • stop not work
    • Vi/Vim
      • Hotkeys
    • parted
      • Create over 2TB partition
    • lsyncd
    • mdadm
      • /boot on RAID1
  • MySQL
    • Типы таблиц (ENGINE)
    • Доступ для пользователя
    • Xtrabackup
    • WSREP - help
    • Примитивы
  • NetWork
    • OpenVPN
    • Установка Pure-FTP
  • Ansiblya
    • unmanaged files
  • Restore
    • Safest way to clean up boot partition
  • Редис
    • High Performance Redis
  • SSL
    • API cloudflare
    • bundel
  • Apache
    • Nginx, Apache, REMOTE_ADDR 127.0.0.1
  • Openresty/Nginx
    • default, Not $host
    • NGINX+Lua=parser_ip
    • NGINX+Lua=Size_img
  • Mong0
  • Mac
    • VirtualBox
  • Hobby
    • 🖖XMage
Powered by GitBook
On this page
  1. Linux
  2. Comand0s

grep

Поиск по файлам

grep -rnw '/etc/mysql/' -e '127'

  • -r or -R is recursive,

  • -n is line number, and

  • -w stands for match the whole word.

  • -l (lower-case L) can be added to just give the file name of matching files.

Along with these, --exclude, --include, --exclude-dir flags could be used for efficient searching:

  • This will only search through those files which have .c or .h extensions:

    grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
  • This will exclude searching all the files ending with .o extension:

    grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
  • For directories it's possible to exclude a particular directory(ies) through --exclude-dir parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:

    grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"

PreviousdisckNextlink

Last updated 5 years ago