Как игнорировать несколько файлов с помощью `ag` Серебряный искатель

В качестве альтернативы вы можете использовать пасту и вырезать :

paste -d'|' <(cut -d'|' -f1 file1) <(cat file2) <(cut -d'|' -f3 file2)

Я не могу сказать, что лучше с точки зрения скорости.

5
04.05.2017, 01:17
3 ответа

Вы можете использовать расширение фигурной скобки, например.

ag pattern --ignore={'*assets*','*scripts*'}  path_to_search

или, как предлагает Гленн здесь, замена процесса:

ag pattern -p <(printf "*%s*\n" assets scripts) path_to_search
12
27.01.2020, 20:37

Вы можете добавить

*assets*
*scripts*

в свой файл .gitignore или .ignore.

Из файла readme:

It ignores file patterns from your .gitignore and .hgignore.
If there are files in your source repo you don't want to search, 
just add their patterns to a .ignore file. 
1
27.01.2020, 20:37

формат--игнорировать шаблон от _до _исключить

➜  proj git:(develop) ✗ ag User -l  | wc
     82      82    2951
➜  proj git:(develop) ✗ ag User -l --ignore 'tests*' | wc
     65      65    2348

доказательство

➜  exp tree                                              
.
├── good.py
├── migrations.py
├── test2.py
├── test_another.py
└── tests.py

➜  for i in *.py; do echo "User" > $i; done 
➜  exp ag -l --ignore 'test*' --ignore 'migrations*' User
good.py

поэтому был возвращен только один файл good.py , все остальные были отфильтрованы по шаблону

1
27.01.2020, 20:37

Теги

Похожие вопросы