Peer-reviewed code snippets that anyone can edit
A wiki for useful code snippets
find C symbols recursively into all subdirs
#!/bin/bash
 
if [ -z "$1" ]; then
    echo "$0 is a tool to fast-find C symbols recursively into all subdirs"
    echo "in .c .cxx .cpp .h files"
    echo "it uses a combination of 'find' and 'grep'"
    echo
    echo sintax:    
    echo    $0 "<regex-pattern>"
    exit 1
else
    pattern=$1
    shift
fi
 
if [ -z "$1" ]; then
    dirs="."
else
    dirs="$*"
    shift
fi
 
find $dirs \( -name "*.c" -or -name "*.h" -or -name "*.cpp" -or -name "*.cxx" \) -exec grep -in "$pattern" {} \; -print