Search code examples
bashshellunixscriptinggit-stash

Search for a string under src using shell script


I basically wanted to search for some sql stored procs in the code. For Eg:

video.sf_get_video_topology , video.sf_get_vod_entitlements, video.sf_get_account_service_cd 

etc.

There are a lot of files and folders under src. I basically wanted to search all of the files and retrieve where this could be referenced. Any pointers what commands i can use to achieve the same


Solution

  • grep is your friend.

    You should look into the -r option to go recursively through directories, and the -l option to only list filenames and not emit the matching lines.

    The syntax is grep [args] [regex] file

    e.g.

    grep -rl "video.sf_get_video_topology" src/*
    

    grep and regex's can be pretty powerful but also easy to make mistakes with, so I'd advise reading up on the man page there.