Use grep to find files matching several file types that contain certain phrasses


Results 1 to 1 of 1

Thread: Use grep to find files matching several file types that contain certain phrasses

  1. #1
    Join Date
    Apr 2014
    Posts
    35

    Use grep to find files matching several file types that contain certain phrasses

    Hello dear members,

    im having linux bash script to search around 30 pathes for files that contains phrasses from my phrasses file. This is the command used:

    /bin/nice -n 19 grep -sRil "$phrasse" /home/$foldername/public_html >> filesmatchingphrasses

    There is quite big amount of phrasses and foldernames and search is done thru many files so i would like to allow grep (or any other linux command?) to examine only files of around 5 certain file types. Example: .php, .htm, .html

    I wanted to ask how can i modiffy my command? Or is there any command that is less intensive on server resources?

    ----
    there is "find" alternative command, but i wish i use grep as i think find somehow did not worked properly to output files matching phrasses.

    there is an simply looking grep command but im little bit afraid to run it so it do not cause anything bad

    there appears to be good ideas for both grep and find

    Should i just add:
    --include=*.{html,php,htm}
    into my command? i added it after "-sRil" part and it appears to work
    Last edited by postcd; 12-31-2015 at 07:06 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •