linux - Comment puis-je récursivement grimper tous les répertoires et sous-répertoires

Mots clés : linuxunixgreplinux

meilleur 5 Réponses linux - Comment puis-je récursivement grimper tous les répertoires et sous-répertoires

vote vote

94

grep -r "texthere" . 
vote vote

82

grep -r --include "*.txt" texthere . 
vote vote

80

grep --include="*.xxx" -nRHI "my Text to grep" * 
--include=PATTERN 
-n, --line-number 
-R, -r, --recursive 
-H, --with-filename 
-I      
/home/vonc/gitpoc/passenger/gitlist/github #grep --include="*.php" -nRHI "hidden" * src/GitList/Application.php:43:            'git.hidden'      => $config->get('git', 'hidden') ? $config->get('git', 'hidden') : array(), src/GitList/Provider/GitServiceProvider.php:21:            $options['hidden'] = $app['git.hidden']; tests/InterfaceTest.php:32:        $options['hidden'] = array(self::$tmpdir . '/hiddenrepo'); vendor/klaussilveira/gitter/lib/Gitter/Client.php:20:    protected $hidden; vendor/klaussilveira/gitter/lib/Gitter/Client.php:170:     * Get hidden repository list vendor/klaussilveira/gitter/lib/Gitter/Client.php:176:        return $this->hidden; ... 
vote vote

60

find ./ -type f -print0 | xargs -0 grep "foo" 
vote vote

54

grep "texthere" **/*.txt 
git grep "pattern" 
rg "pattern" . 

Questions similaires