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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
You might want to check out http://ss64.com/bash/grep.html (or man grep) for other examples.