How to search for files containing specific word?












32















How to search for files containing specific word?










share|improve this question


















  • 5





    Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

    – dr_willis
    May 2 '11 at 13:39


















32















How to search for files containing specific word?










share|improve this question


















  • 5





    Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

    – dr_willis
    May 2 '11 at 13:39
















32












32








32


20






How to search for files containing specific word?










share|improve this question














How to search for files containing specific word?







command-line






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 2 '11 at 12:27









UAdapterUAdapter

5,312346693




5,312346693








  • 5





    Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

    – dr_willis
    May 2 '11 at 13:39
















  • 5





    Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

    – dr_willis
    May 2 '11 at 13:39










5




5





Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

– dr_willis
May 2 '11 at 13:39







Do you actually mean search file NAMES containing with a specific word in them? ie: all files that have the term FUN in their names, , FUN_time.txt FUN_stuff.txt Or search INSIDE a file for specific words?

– dr_willis
May 2 '11 at 13:39












4 Answers
4






active

oldest

votes


















46














With command line you have several options. The 3 I use the most are...





  1. locate {part_of_word}



    This assumes your locate-database is up to date but you can update this manually with: sudo updatedb




  2. grep as explained by dr_willis.
    One remark: -R after grep also searched within directories.
    Example:



    cd
    grep -R {something_to_look_for} {where_to_look_in}


  3. find . -name '*{part_of_word}*' -print



Where . is the directory where you are at the moment and * is a wildcard.



Oh and you can also combine these. Example:
locate {something}|grep {some_part_of_something}|more



If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.






share|improve this answer

































    22














    grep -R "what" "where"



    example:



    grep -R hello /home






    share|improve this answer































      4














      The grep command is commonly used for this.



      grep PATTERN filename



      and grep can do some very complex searching.



      willis@Cow:~$ grep --help
      Usage: grep [OPTION]... PATTERN [FILE]...
      Search for PATTERN in each FILE or standard input.
      PATTERN is, by default, a basic regular expression (BRE).
      Example: grep -i 'hello world' menu.h main.c





      share|improve this answer



















      • 3





        or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

        – Jeremy Bicha
        May 2 '11 at 12:48



















      3














      You can use grep to list the files containing word in the given directory:



      grep -Ril word directory


      Here:

      * -R recursively search files in sub-directories.

      * -i ignore text case

      * -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).



      use man grep to get all the options






      share|improve this answer





















      • 3





        Just so you know: -i performs a case-insensitive search.

        – David Foerster
        Feb 11 '16 at 10:21













      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "89"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f39200%2fhow-to-search-for-files-containing-specific-word%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      46














      With command line you have several options. The 3 I use the most are...





      1. locate {part_of_word}



        This assumes your locate-database is up to date but you can update this manually with: sudo updatedb




      2. grep as explained by dr_willis.
        One remark: -R after grep also searched within directories.
        Example:



        cd
        grep -R {something_to_look_for} {where_to_look_in}


      3. find . -name '*{part_of_word}*' -print



      Where . is the directory where you are at the moment and * is a wildcard.



      Oh and you can also combine these. Example:
      locate {something}|grep {some_part_of_something}|more



      If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.






      share|improve this answer






























        46














        With command line you have several options. The 3 I use the most are...





        1. locate {part_of_word}



          This assumes your locate-database is up to date but you can update this manually with: sudo updatedb




        2. grep as explained by dr_willis.
          One remark: -R after grep also searched within directories.
          Example:



          cd
          grep -R {something_to_look_for} {where_to_look_in}


        3. find . -name '*{part_of_word}*' -print



        Where . is the directory where you are at the moment and * is a wildcard.



        Oh and you can also combine these. Example:
        locate {something}|grep {some_part_of_something}|more



        If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.






        share|improve this answer




























          46












          46








          46







          With command line you have several options. The 3 I use the most are...





          1. locate {part_of_word}



            This assumes your locate-database is up to date but you can update this manually with: sudo updatedb




          2. grep as explained by dr_willis.
            One remark: -R after grep also searched within directories.
            Example:



            cd
            grep -R {something_to_look_for} {where_to_look_in}


          3. find . -name '*{part_of_word}*' -print



          Where . is the directory where you are at the moment and * is a wildcard.



          Oh and you can also combine these. Example:
          locate {something}|grep {some_part_of_something}|more



          If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.






          share|improve this answer















          With command line you have several options. The 3 I use the most are...





          1. locate {part_of_word}



            This assumes your locate-database is up to date but you can update this manually with: sudo updatedb




          2. grep as explained by dr_willis.
            One remark: -R after grep also searched within directories.
            Example:



            cd
            grep -R {something_to_look_for} {where_to_look_in}


          3. find . -name '*{part_of_word}*' -print



          Where . is the directory where you are at the moment and * is a wildcard.



          Oh and you can also combine these. Example:
          locate {something}|grep {some_part_of_something}|more



          If I recall correctly: locate is the fastest one (assuming your database is up to date) and find is the slowest one. And grep is the most complex but also the most versatile one of these since you can use regexes.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 21 '15 at 18:04









          Fabby

          26.9k1360161




          26.9k1360161










          answered May 2 '11 at 12:48









          RinzwindRinzwind

          207k28398528




          207k28398528

























              22














              grep -R "what" "where"



              example:



              grep -R hello /home






              share|improve this answer




























                22














                grep -R "what" "where"



                example:



                grep -R hello /home






                share|improve this answer


























                  22












                  22








                  22







                  grep -R "what" "where"



                  example:



                  grep -R hello /home






                  share|improve this answer













                  grep -R "what" "where"



                  example:



                  grep -R hello /home







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 2 '11 at 13:21









                  DemonWareXTDemonWareXT

                  90167




                  90167























                      4














                      The grep command is commonly used for this.



                      grep PATTERN filename



                      and grep can do some very complex searching.



                      willis@Cow:~$ grep --help
                      Usage: grep [OPTION]... PATTERN [FILE]...
                      Search for PATTERN in each FILE or standard input.
                      PATTERN is, by default, a basic regular expression (BRE).
                      Example: grep -i 'hello world' menu.h main.c





                      share|improve this answer



















                      • 3





                        or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                        – Jeremy Bicha
                        May 2 '11 at 12:48
















                      4














                      The grep command is commonly used for this.



                      grep PATTERN filename



                      and grep can do some very complex searching.



                      willis@Cow:~$ grep --help
                      Usage: grep [OPTION]... PATTERN [FILE]...
                      Search for PATTERN in each FILE or standard input.
                      PATTERN is, by default, a basic regular expression (BRE).
                      Example: grep -i 'hello world' menu.h main.c





                      share|improve this answer



















                      • 3





                        or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                        – Jeremy Bicha
                        May 2 '11 at 12:48














                      4












                      4








                      4







                      The grep command is commonly used for this.



                      grep PATTERN filename



                      and grep can do some very complex searching.



                      willis@Cow:~$ grep --help
                      Usage: grep [OPTION]... PATTERN [FILE]...
                      Search for PATTERN in each FILE or standard input.
                      PATTERN is, by default, a basic regular expression (BRE).
                      Example: grep -i 'hello world' menu.h main.c





                      share|improve this answer













                      The grep command is commonly used for this.



                      grep PATTERN filename



                      and grep can do some very complex searching.



                      willis@Cow:~$ grep --help
                      Usage: grep [OPTION]... PATTERN [FILE]...
                      Search for PATTERN in each FILE or standard input.
                      PATTERN is, by default, a basic regular expression (BRE).
                      Example: grep -i 'hello world' menu.h main.c






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 2 '11 at 12:33









                      dr_willisdr_willis

                      3771211




                      3771211








                      • 3





                        or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                        – Jeremy Bicha
                        May 2 '11 at 12:48














                      • 3





                        or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                        – Jeremy Bicha
                        May 2 '11 at 12:48








                      3




                      3





                      or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                      – Jeremy Bicha
                      May 2 '11 at 12:48





                      or you can do "rgrep word ." to recursively search every file and subdirectory for "word"

                      – Jeremy Bicha
                      May 2 '11 at 12:48











                      3














                      You can use grep to list the files containing word in the given directory:



                      grep -Ril word directory


                      Here:

                      * -R recursively search files in sub-directories.

                      * -i ignore text case

                      * -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).



                      use man grep to get all the options






                      share|improve this answer





















                      • 3





                        Just so you know: -i performs a case-insensitive search.

                        – David Foerster
                        Feb 11 '16 at 10:21


















                      3














                      You can use grep to list the files containing word in the given directory:



                      grep -Ril word directory


                      Here:

                      * -R recursively search files in sub-directories.

                      * -i ignore text case

                      * -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).



                      use man grep to get all the options






                      share|improve this answer





















                      • 3





                        Just so you know: -i performs a case-insensitive search.

                        – David Foerster
                        Feb 11 '16 at 10:21
















                      3












                      3








                      3







                      You can use grep to list the files containing word in the given directory:



                      grep -Ril word directory


                      Here:

                      * -R recursively search files in sub-directories.

                      * -i ignore text case

                      * -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).



                      use man grep to get all the options






                      share|improve this answer















                      You can use grep to list the files containing word in the given directory:



                      grep -Ril word directory


                      Here:

                      * -R recursively search files in sub-directories.

                      * -i ignore text case

                      * -l show file names instead of file contents portions. (note: -L shows file names that do not contain the word).



                      use man grep to get all the options







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Feb 15 at 2:41

























                      answered Apr 29 '15 at 17:47









                      chandanchandan

                      181119




                      181119








                      • 3





                        Just so you know: -i performs a case-insensitive search.

                        – David Foerster
                        Feb 11 '16 at 10:21
















                      • 3





                        Just so you know: -i performs a case-insensitive search.

                        – David Foerster
                        Feb 11 '16 at 10:21










                      3




                      3





                      Just so you know: -i performs a case-insensitive search.

                      – David Foerster
                      Feb 11 '16 at 10:21







                      Just so you know: -i performs a case-insensitive search.

                      – David Foerster
                      Feb 11 '16 at 10:21




















                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Ask Ubuntu!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f39200%2fhow-to-search-for-files-containing-specific-word%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                      Mangá

                       ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕