find . -name <file-pattern> -exec <command> {} \;
Examples
To grep for "hello" inside all .txt files:find . -name *.txt -exec grep -Hn hello {} \;
Put this in a shell script to recursively grep .cpp and .hpp files for the first argument:
#!/bin/bash
find . -name *.[ch]pp -exec grep -Hn "$1" {} \;
No comments:
Post a Comment