You can use multiple --include
flags. This works for me:
grep -r --include=*.html --include=*.php --include=*.htm "pattern" /some/path/
However, you can do as Deruijter suggested. This works for me:
grep -r --include=*.{html,php,htm} "pattern" /some/path/
Don’t forget that you can use find
and xargs
for this sort of thing too:
find /some/path/ -name "*.htm*" -or -name "*.php" | xargs grep "pattern"
Related Contents:
- How to make grep only match if the entire line matches?
- How to print lines between two patterns, inclusive or exclusive (in sed, AWK or Perl)?
- How to use SSH to run a local shell script on a remote machine?
- What’s the difference between .bashrc, .bash_profile, and .environment?
- How to delete from a text file, all lines that contain a specific string?
- How to ‘grep’ a continuous stream?
- Using cURL to upload POST data with files
- Check if a file exists with a wildcard in a shell script [duplicate]
- How to read a file into a variable in shell?
- Global environment variables in a shell script
- How do I kill background processes / jobs when my shell script exits?
- Capturing Groups From a Grep RegEx
- How could the UNIX sort command sort a very large file?
- How can I shuffle the lines of a text file on the Unix command line or in a shell script?
- What does $$ mean in the shell?
- Test if remote TCP port is open from a shell script
- Getting the last argument passed to a shell script
- Can GNU make handle filenames with spaces?
- What is /dev/null 2>&1?
- How to remove carriage return from a variable in shell script
- Using awk with variables
- How to insert a newline in front of a pattern?
- How/When does Execute Shell mark a build as failure in Jenkins?
- Alternative to `sed -i` on Solaris
- What’s an easy way to read random line from a file?
- Meaning of $? (dollar question mark) in shell scripts
- How does the #! shebang work?
- How do I copy a folder from remote to local using scp?
- Is there an Eclipse plugin to run system shell in the Console? [closed]
- Shell command to find lines common in two files
- in mac always getting zsh: command not found: [closed]
- How to set child process’ environment variable in Makefile
- How can I negate the return-value of a process?
- How do you catch error codes in a shell pipe?
- How to get the second column from command output?
- Passing argument containing space in shell script
- Ansible Command module says that ‘|’ is illegal character
- Do a tail -F until matching a pattern
- Finding contents of one file in another file
- “No such file or directory” but it exists
- Why 0 is true but false is 1 in the shell?
- Can I ssh somewhere, run some commands, and then leave myself a prompt?
- Is there a “standard” format for command line/shell help text?
- How to do a non-greedy match in grep?
- How to ssh to vagrant without actually running “vagrant ssh”?
- How to source a script in a Makefile?
- CMake’s execute_process and arbitrary shell scripts
- Remove part of path on Unix
- Write byte at address (hexedit/modify binary from the command line)
- nginx: use environment variables