Grep «Шаблон 2» только в файлах, содержащих «Шаблон 1»

Puede probar el indicador --install, que debería hacer que sus repositorios estén disponibles después de la instalación, por ejemplo

repo --install --name="DockerCE" --baseurl="https://download.docker.com/linux/centos/7/x86_64/stable/"

Enlace a más documentación. Busque la sección "repo".

0
15.07.2019, 13:24
1 ответ

Вы можете подключиться кxargs:

grep -rlZ "Pattern 1" | xargs -0 grep -l "Pattern 2"

или используйте findи grep -q+grep -l:

find. -type f \
  -exec grep -q "Pattern 1" {} \; \
  -exec grep -l "Pattern 2" {} +

Вариант xargs, вероятно, более эффективен, так как он будет вызывать grepдля нескольких файлов одновременно, а findбудет вызывать grepдля каждого файла.

0
28.04.2021, 23:31

Теги

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