Grep a list of specific files

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I need to grep for a string but only within certain files within a directory- eg:

grep -rl mystring "file1.txt file2.txt file3.blah"

what is the correct syntax? I am working in a Linux OS.

Answers

Drop the quotes around the file names so that they are treated as separate parameters. Also, I don t think you need the -r since you are just specifying files and not folders.

grep  mystring file1.txt file2.txt file3.blah

http://ss64.com/bash/grep.html http://ss64.com/bash/grep.html

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/12389611/grep-a-list-of-specific-files

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils